← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #271206]: Searching.. for X amount of time instead of waiting

 

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

RaiMan proposed the following answer:
masuo's answer is "half correct": exists() allows to set a maximum
waiting time.

... but the the actual find() with a waiting time is using wait()

instead of 
find(image) # waits max 3 seconds then crashes

use
wait(image, timeInSeconds)  # waits max timeInSeconds then crashes

... the difference between exists() and wait():
- wait() crashes with not found (use try: ... except: ... to catch the FindFailed exception)
- exists() just returns a None match and script continues

... hence the preferred usage situation of exists() is to check the returned match and make ma decision how to continue:
if exists(image):
    click() # clicks image if found
else:
    click(somethingElse) # the alternative way

BTW: to setup scripted workflows with SikuliX just means to learn some
basic Python language, if you need a bit more logic than just a serious
of wait/click/wait/type.... actions.

consult the docs:
http://sikulix-2014.readthedocs.org/en/latest/index.html

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.