Find

Asked by Natanael Morais

What is the difference between the function Exists and Find?

I was using in my code the function Exists and I tried to use Find, but the image I was looking for the Sikuli didn't find.
I'm writing my code in Java with Netbeans.
Cheers.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Eugene S
Solved:
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

When using "exists":
1. You can specify the wait time (in seconds)
2. None is returned, if nothing is found within the specified waiting time
3. Does exactly the same as Region.wait(), but no exception is raised in case of FindFailed

When using "find":
1. FindFailed exception is returned if nothing was found
2. If autoWaitTimeout is set to a non-zero value, find() just acts as a wait()

All that described in the doco, you can find here:
http://doc.sikuli.org/region.html#Region.exists
http://doc.sikuli.org/region.html#Region.find

Cheers,
Eugene

Revision history for this message
Natanael Morais (natanael) said :
#2

Thank you for the answer, that is what I was thinking.
But Is there a reason for the function Find didn't find a image that I'm looking for? Because the function Exists worked correctly with the same image.

Revision history for this message
Best Eugene S (shragovich) said :
#3

As much as I am aware, both - exists() and find() have a default wait time of 3 sec. So I would expect them to work similarly.
Are you using any of the below settings?

setAutoWaitTimeout()
or
setThrowException()

Revision history for this message
Natanael Morais (natanael) said :
#4

I understood.
No I'm not using, but that solved my problem.
Thaks a lot.

Revision history for this message
Natanael Morais (natanael) said :
#5

Thanks Eugene S, that solved my question.