← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #678325]: If it Can't Find, Closes Early

 

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

RaiMan posted a new comment:
You have to fully understand, how SikuliX internally works.

This might be helpful:
https://sikulix-2014.readthedocs.io/en/latest/basicinfo.html#sikulix-how-does-it-find-images-on-the-screen

... so it is all about timing.

When searching an image on the whole screen, a search op might take up
to 500 msec, which then is repeated until found or wait time is elapsed
(FindFailed exception).

So for critical parts of your workflow or GUI's that change without
being acted on, you have to adjust your search timing.

This should generally be avoided:
if has(image):
   click(image)

.... if it comes to the click op, then the image was already found some milli-seconds before.
but saying click(image) will start a new search, which at least costs some 10 msecs and might lead to FindFailed in fast changing GUI situations.

so either say:
if has(image):
   click()

which is short for:
if has(image):
   click(getLastMatch())

another option is to use:
click(wait(image, waitTime))

which will either click (meaning found) or throw a FindFailed.

In the end, you have to find your own way based on the knowledge of how
SikuliX works and about the timing of your automated GUI.

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