← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #275951]: Adding logic via IF, ELSE statement in Sikuli Java API using the exist method

 

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

    Status: Open => Answered

jm.trappier@xxxxxxxxx proposed the following answer:
Hello,

I'm not really a specialist but for what I've seen so far, the main
difference between "find" and "exists" is that find will raise a
FindFailed exception in case no match was found when "exists" won't
raise it, it will just return null. If think you can use :

if(s.exists(imagePath) != null){s.rightClick(imagePath)}

You can add a timeout with exists, just like this :

if(s.exists(imagePath, 2) != null){s.rightClick(imagePath)}

I may be wrong, I'm not a java specialist and just begining to use
sikuliX (and testing java at the moment, 10 minutes long :p) but I think
it will do the trick.

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