sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #01626
Re: [Question #147764]: Basic If usage: Look for image, if not found skip to
Question #147764 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/147764
Status: Open => Answered
RaiMan proposed the following answer:
find() cannot be used in if/elif/while, since it does not return if not
found, but stops the script with a FindFailed exception.
The appropriate method is exists(), which is functionally equivalent,
but returns None in this case.
the most compact form for such cases:
click(exists(<logout-image, 0)) # , 0) means only search once, no 3
seconds wait for image
this would click the match found by exists() or does nothing in case not
found.
or in long form if you want to add more scripting:
if exists(<logout-image>, 0):
click(getLastMatch()) # avoids another find() operation
wait(2)
# some more code
# after the if
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.