← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #209147]: if exists with try catch

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--1. if exists(Pattern("file.png'").similar(0.95)):
--2.  click ("file.png'')

You say, 2 works, but 1 does not.

So I guess, that your screenshot file.png is so bad (too much background
??), that it does not get a score of at least .95.

To compare the 2 solutions you must use

either
--1. if exists("file.png"):
--2.  click ("file.png'')

or
--1. if exists(Pattern("file.png'").similar(0.95)):
--2.  click (Pattern("file.png'").similar(0.95))

If in doubt about similarity score, it is always a good idea to use
highlight(), which gives you a visual feedback and prints the match
showing the score.

e.g.
click("file.png")
getLastMatch().highlight(2) # for debugging only

then you can use the score, to optimize the exists()

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