sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #42518
Re: [Question #632251]: How to create new Keywords on Roboframework integrated with Sikuli
Question #632251 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/632251
RaiMan proposed the following answer:
ok, sorry, again, since you cannot edit an answer here:
if __name__ == "__main__":
calc = LoginLibrary()
calc.runTest()
... is not needed generally in SikuliX scripts and not reached in this
case anyways.
Go back and read carefully about how this magic feature of SikuliX works:
http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#using-robotframework
... then you will understand, that this is the final script code, that is run:
runScript("""
robot
***Settings***
Library ./inline/LoginLibrary
***Test Cases***
Verify that 2 + 2 = 4
start App
verify App
Verify that 2 + 2 = 5
start App
verify App
""")
by internally handing this over to robot.
... and this is the keywords-defining class, that is temporarily stored
somewhere and the pointer is placed instead of ./inline/LoginLibrary, so
robot can import it. This class definition is not part of the final
internal script code, since everything after the """) is stripped off.
class LoginLibrary(object):
def __init__(self):
self.appCoordinates = (0, 0, 1024, 768)
def start_App(self):
calcApp = App("Calculator")
if not calcApp.window():
App.open("calc.exe");
wait(2)
calcApp.focus();
wait(1)
def verify_App(self):
if exists ("CalcApp.png"):
print("Calc window appeared")
else:
print("No Calc window")
So as mentioned in the docs, it is simply this:
runScript("""
robot
***Settings***
Library ./inline/LoginLibrary
***Test Cases***
Verify that 2 + 2 = 4
start App
verify App
Verify that 2 + 2 = 5
start App
verify App
""")
class LoginLibrary(object):
def __init__(self):
self.appCoordinates = (0, 0, 1024, 768)
def start_App(self):
calcApp = App("Calculator")
if not calcApp.window():
App.open("calc.exe");
wait(2)
calcApp.focus();
wait(1)
def verify_App(self):
if exists ("CalcApp.png"):
print("Calc window appeared")
else:
print("No Calc window")
might be a copy&paste problem: since this is Python language, you have
to take care for correct and consistent indentation.
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.