onAppear Vs exists

Asked by Djg

Hi,

Can you please let me know when to use onAppear and when to use exists. Which is more efficient.
I have say 25 images in a table format (5X5). The images are not in the same order. I will navigate from 1st image till the 25th image. As i navigate the image gets highlighted and when a particular image is highlighted i need to display a popup.

I can use a while loop along with exists or onAppear for this? I would like to know the answers for above question atleast with respect to this scenario.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Generally spoken, using the observer feature (onAppear(), ...) () is more complex than using exists and so it only makes sense in situations, where you want to wait for something in the background or in parallel to your normal workflow (e.g. a popup, that appears in a not predictable way).

If you want to find something inline with your workflow (with or without extensive waiting), exists() is the first choice (easy and straight forward), if you want to avoid script aborts with FindFailed exceptions.

*** Your solution:
You may use a loop and exists() at every image position with the image probe you are looking for. This will take some time (in average 12.5 x time-to-check-one-image).
But why not make one exists() on the whole table region and then calculate the table position of the found image based on the coordinates of the match.

Can you help with this problem?

Provide an answer of your own, or ask Djg for more information if necessary.

To post a message you must log in.