First of all let me tell you that I am new to Sikuli. I have developed some scripts using the Sikuli IDE and it works fine.
But when i created class and have added the tests as methods to it..it does not work. Can someone let me know what am I missing here. my sikuli script is like this:
class Test:
def setUp(self):
openApp("abc")
wait(10)
def tearDown(self):
closeApp("abc")
def test1(self):
click("1401168929740.png")
time.sleep(1)
type('o')
time.sleep(3)
click("1401169004890.png")
wait("1401169047733.png")
type("some text here")
time.sleep(2)
click("1401169154910.png")
time.sleep(10)
print("the outcome")
def test2(self):
wait("1401169193096.png")
click("1401100914478.png")
time.sleep(3)
print("the outcome")
def test3(self):
type("m", KEY_ALT)
type("cus1")
type(Key.ENTER)
time.sleep(2)
type(Key.TAB)
time.sleep(2)
type("10.00")
time.sleep(2)
type(Key.TAB)
time.sleep(2)
type(Key.TAB)
time.sleep(2)
type(Key.ENTER)
time.sleep(3)
type(Key.ENTER)
time.sleep(17)
type(Key.ENTER)
time.sleep(10)
def test4(self):
if exists("1401100952048.png"):
popup("the outcome")
else:
popup("failure message")
I'm no expert, but I'm not sure if a class is what you really want...I question if you really do want a class, because it doesn't look like you're meaning for your Test class to have different attributes, just different pieces of code that will execute.
If you're wanting to wrap up these definitions into one easy-to-call piece of code, you could do it like this--
After defining all of the functions you have listed above, you could define one more function that includes them all:
If you really did want a class, seeing how you're implementing the class could help us see where the problem is. If you want to keep these methods inside the class, then I think the proper way to call them is:
There is a good discussion about how to construct classes in python here (particularly the second answer).