Stable tests, Exist() + Click()

Asked by shaihulud

The application under test sometimes has longer loading times, and if I use the simple click() the loading time is longer then the time sikuli takes to look for the image.
So I have ended up writing
exist(img1, 10), click(img1)
This works as sikuli will wait 10 seconds for the img1 to appear and then click it.
But having large tests this takes a long time to write and Im wondering if theres an easier way?
I noticed click() can have a [modifier] but didn´t find any solution. Im thinking of having a developer here write a code for a new function otherwise to save time ;)

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
shaihulud
Solved:
Last query:
Last reply:
Revision history for this message
shaihulud (cal-a) said :
#1

Ok, sorry for taking your time, I solved it myself. What I did was:

def Eclick(img):
    exists(img, 10)
    click(img)

Eclick(img)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

This would be better:
click(exists(img, 10))
... only one search

But this is risky:
you do not notice when it fails.

Revision history for this message
shaihulud (cal-a) said :
#3

Thanks for an additional solution but as you say debugging would be tricky. And there will probably be alot of that ;-) So searching one time instead of two doesnt really compensate that.