← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #191510]: Problem in if else

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This is the most efficient way, to do something like that:

if exists("follow.png", 0): click(getLastMatch())
elif exists("circles.png", 0): click(getLastMatch())
else click("cross-button.png")

This takes max 1 second, if neither follow nor circle exist (compared to
about 7 seconds with the original solution, if it works).

With this kind of decisions one should always use exists("image.png",
0), since this comes back after one search, whereas exists() waits 3
seconds.

With exists("image.png", 0) each additional search case would add only
about 1/2 second, if not found.

as (j-the-k) already mentioned: take care for the indentation (see faq
1800)

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