← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #213271]: wait problems and cut-off screen

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Yes, that's some kind of "misunderstanding".

find, wait, click and all the other features, that include a search
operation internally throw a FindFailed if the intended search operation
does not succeed

wait(image)  and find(image) are exactly the same: If the image does not appear within 3 seconds (the default) you get the find failed and the script aborts.
But only the wait() has an option to specify a longer waiting time. But if image does not appear within the given time, this is taken as a "not Found" and hence FindFailed and script aborts.

But for these we have exists(), which is the same as wait, with one
exception: it does not throw FindFailed, but returns None if not found,
so you can use it for decisions.

so the above would simply be:

if not exists(image, 5):
    print "image did not appear within 5 seconds"; exit()
click(getLastMatch()) # this would click the center of the found match

There are some very valuable hints in the faqs on this page and surely
in the docs.

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