sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #06095
Re: [Question #173899]: Robot Framework Problem
Question #173899 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/173899
Peter Kim gave more information on the question:
RaiMan,
I changed robottest.bat as following:
@echo off
set sikuli_jar=D:\Program Files\Sikuli X\sikuli-script.jar
java -cp "%sikuli_jar%" ^
-Dpython.path=<absoluete-path-to>calc.sikuli ^
-jar robotframework-2.5.5.jar ^
--outputdir=results ^
--loglevel=TRACE ^
%*
I then got following error messages:
D:\Sikuli\RobotFramework>robottest.bat robot_suite\verify_operations.txt
[ ERROR ] Invalid syntax in file 'd:\sikuli\robotframework\robot_suite\verify_operations.txt' in table 'Settings': Importing test library 'calc.Calculator' failed: ImportError: No module named sikuli
PYTHONPATH: ['D:\\Sikuli\\RobotFramework\\robotframework-2.5.5.jar\\Lib\\robot\\libraries','D:\\Sikuli\\RobotFramework\\calc.sikuli', 'D:\\Sikuli\\RobotFramework\\Lib','D:\\Sikuli\\RobotFramework\\robotframework-2.5.5.jar\\Lib', '__classpath__', '__pyclasspath__/', '.']
CLASSPATH: robotframework-2.5.5.jar
Traceback (most recent call last):
File "D:\Sikuli\RobotFramework\robotframework-2.5.5.jar\Lib\robot\utils\importing$py.class", line 94, in _import
File "D:\Sikuli\RobotFramework\calc.sikuli\calc.py", line 2, in <module>
from sikuli.Sikuli import *
File "D:\Sikuli\RobotFramework\Lib\sikuli\__init__.py", line 3, in <module>
from Sikuli import *
File "D:\Sikuli\RobotFramework\Lib\sikuli\Sikuli.py", line 10, in <module>
from org.sikuli.script import SikuliScript
I then added "%sikuli_jar%/Lib" to -Dpython.path. robottest.bat looked
like following:
@echo off
set sikuli_jar=D:\Program Files\Sikuli X\sikuli-script.jar
java -cp "%sikuli_jar%" ^
-Dpython.path=D:\Sikuli\RobotFramework\calc.sikuli;"%sikuli_jar%/Lib" ^
-jar robotframework-2.5.5.jar ^
--outputdir=results ^
--loglevel=TRACE ^
%*
I then received the following error message:
D:\Sikuli\RobotFramework>robottest.bat robot_suite\verify_operations.txt
Exception in thread "main" Traceback (most recent call last):
File "<string>", line 1, in <module>
File "D:\Sikuli\RobotFramework\robotframework-2.5.5.jar\Lib\robot\__init__$py.class", line 16, in <module>
File "D:\Program Files\Sikuli X\sikuli-script.jar\Lib\os.py", line 118, in <module>
ImportError: no os specific module found
Here is calc.py:
from __future__ import with_statement
from sikuli.Sikuli import *
class Calculator(object):
def __init__(self):
self.appCoordinates = (0, 0, 1024, 768)
def startApp(self):
calcApp = App.open("calc.exe"); wait(2)
calcApp.focus(); wait(1)
def verifyApp(self):
# check application
if exists("calculator.png"):
print("PASS: Calculator window appeared")
else:
print("FAIL: No calculator window")
def performAction(self, *args):
# get application region
find("calculator.png")
match = 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:
Settings.MinSimilarity = 0.99
click("btnC.png")
click( "btn%s.png" % (args[0],) )
click( "btn%s.png" % (action,) )
click( "btn%s.png" % (args[2],) )
click("btnEqual.png")
Settings.MinSimilarity = 0.70
def verifyResult(self, *args):
expected_result = str(eval(''.join(args)))
actual_result = self.getResultFromClipboard()
#verification
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()
#"btn2.png"
#"btnEqual.png"
#"btnC.png"
#"btnPlus.png"
#"btnMinus.png"
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.