← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #252490]: [1.0.1] Sikuli integration Robot framework --- use sikuli-java.jar

 

Question #252490 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/252490

balu posted a new comment:
Hi RaiMan,

  Thanks for your reply.

   Followed this steps that Tset suggested. But still I am getting some
errors. Could you please help me to fix this.

  Below is my current situation:

STEP 1 :

My Calc.py contents:
=================

# -*- coding: utf-8 -*-
from __future__ import with_statement

# IMPORTANT: python level import - don´t mix it with java level imports of Sikuli classes
# like from org.sikuli.script import Region
# For more details go here: https://answers.launchpad.net/sikuli/+question/261129
from sikuli import *

setBundlePath("calc.sikuli")

s = Screen()

class Calculator(object):
	
	def __init__(self):
		self.appCoordinates = (0, 0, 1024, 768)
	
	def startApp(self):
		calcApp = App("Calculator")
		if not calcApp.window():
				App.open("calc.exe")
				s.wait(2)
		calcApp.focus()
		s.wait(1)

	def verifyApp(self):
		# check application
		if s.exists("CalcApp.png"):
			print("PASS: Calculator window appeared")
		else:
			print("FAIL: No calculator window")

	def performAction(self, *args):
		# get application region
		s.find("CalcApp.png")
		
		match = s.getLastMatch()
		self.appCoordinates = (match.getX(), match.getY(), match.getW(), match.getH())
		appRegion = Region(*self.appCoordinates)
		
		# rewrite action
		action = args[1]
		if args[1] == '+':
			action = 'Plus'
		elif args[1] == 'exp':
			action = 'Exp'
		
		# with appRegion:
		s.click("btnC.png")

		s.click( "btn%s.png" % (args[0],) )
		s.click( "btn%s.png" % (action,) )
		s.click( "btn%s.png" % (args[2],) )

                s.click("btnEqual.png")

	def verifyResult(self, *args):
		expected_result = str(eval(''.join(args)))
		actual_result = self.getResultFromClipboard()
		
		#verification
		print expected_result
		print actual_result
		if actual_result == expected_result:
			print("PASS: Action performed correctly and result equals %s" % expected_result)
		else:
			print("FAIL: Actual result '%s' is not equal to expected result '%s'" % (actual_result, expected_result))
		
	def getResultFromClipboard(self):
		type('c', KEY_CTRL)
		return str(Env.getClipboard())
		
	def runTest(self):
		self.startApp()
		self.verifyApp()
		
		actions = '2+2'
		self.performAction(*actions)
		self.verifyResult(*actions)

if __name__ == "__main__":
	calc = Calculator()
	calc.runTest()


STEP 2: Verify_operations.txt:
========================

***Settings***
#Library  calc.Calculator  WITH NAME  Calculator
Library C:/Users/symbol/Desktop/Projects/Sikuli Projects/calc.sikuli/calc.py

***Test Cases***

Verify that 2 + 2 = 4
	Start App
	Verify App
	Perform Action  2  +  2
	Verify Result  4

Verify that 2 + 2 = 5
	Start App
	Verify App
	Perform Action  2  +  2
	Verify Result  5

Click on non-existent button "Exp"
	Start App
	Verify App
	Perform Action  2  exp  2
	Verify Result  2


STEP 3: robottest.bat contents:
==========================
 
@echo off

set sikulix_jar=C:\robot\libs\SikuliX_110\sikulixapi.jar
set robot_framework_jar=C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframework-2.5.5.jar

java -cp "%robot_framework_jar%;%sikulix_jar%" ^
     -Dpython.path="%sikulix_jar%/Lib" ^
     org.robotframework.RobotFramework ^
     --pythonpath=calc.sikuli ^
     --outputdir=results ^
     --loglevel=TRACE ^
     %*


STEP 4: 

When I run I am getting following error:

C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli>robottest.bat verif
y_operations.txt
Exception in thread "main" Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli\robotframew
ork-2.5.5.jar\Lib\robot\__init__$py.class", line 16, in <module>
  File "C:\jython2.5.4rc1\Lib\os.py", line 132, in <module>
    raise ImportError, 'no os specific module found'
ImportError: no os specific module found

C:\Users\symbol\Desktop\Projects\Sikuli Projects\calc.sikuli>


I am using "Windows7 32bit".

CLASSPATH :        C:\robot\libs\SikuliX_110\sikulixapi.jar
JYTHONPATH :    C:\jython2.5.4rc1\Lib
SIKULIX_HOME  : C:\robot\libs\SikuliX_110\


Could you please help me to fix this issue. Thanks for your help.


Thanks,
Balu.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.