← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #160813]: How to use if/elif/else correctly

 

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

Vaibhav thakur gave more information on the question:
Haha Thanks :)) 
I've to ask something else. So I tried if exists command, it is not useful, as it makes the sikuli kind of idle. which I think is it cannot find if it exists or not.

Code:
if exists("sikuli-tmp321.png", 0):
	 
	click("OkIlikethepa.png")
	popup("finding clicking like")   
else: 
	wait("5Like.png")
	find("5Like.png")
	click("5Like.png")
	popup("sleep for 5")
sleep(5)
popup("clicking")
click("5Like.png")

So I thought to check if exists operation works with the region.inside() operation. but it didn't work.
Also,I have 3 outcomes 
1)No error
2)Error1
2)Error2
So I've add 2 Else(es) in my script.

CODE:
reg=  (region here)
 reg.highlight(2) # Just checking if it finds the region
reg.inside().if.exists( ):
		popup("it exists")#checking if it exists so command
else:
	click("") #if error 2 is found, clicks skip button for error2
	popup("error2") 
else:
	click("") #main function
	popup("doing job") #if no error is found

Thanks again :)

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