find sometmes fails and sometimes works

Asked by hafsa faiyaz

i have written a sikuli script to launch a browser.the find function sometimes fails and someimes it works.can u pls tell me how to make the find more robust???
openApp("C:\Program Files\Internet Explorer\iexplore.exe")
wait(5)
find("123344.png")
type("times.com")
type(Key.ENTER)
Also when i copy paste the scripts the find function doesnt workpls help me on this

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

-- 1. copy/ paste of scripts inside the IDE (from one tab to another) is not supported yet. You have to save the script with another name and then reload the old one if needed.

-- 2. make find more robust
find() cannot be made "more robust". It either finds the requested image within 3 seconds or it fails, if it cannot be found for whatever reason (it is really not yet there after 8 seconds in your case or other reason).

If it is a timing problem: use wait instead of find:

old:
wait(5)
find("123344.png")

new:
wait("123344.png", 20)

only after 20 seconds you would get your FindFailed

-- 3: comment on your script:
the find is absolutely useless, since it does nothing else than stopping the script after 8 seconds if not found.
Your script works, because when starting the IE, a new window is opened and the focus is on the address field, so your type() works.
So this would work also:
openApp("C:\Program Files\Internet Explorer\iexplore.exe")
wait(8)
type("times.com") # use paste() instead
type(Key.ENTER)

If the window is not ready after 8 secs, you will get some beeps ;-)

-- 4: to make your script "more robust"
you could try to not wait for the IE to open, but for your requested webpage to come up
type(Key.ESC, KEY_CTRL) # should open the start menu
paste("http://times.com") # enters the url into the cmd field
type(Key.ENTER) # fires the url
wait("timesLogo.png", 20)

Can you help with this problem?

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

To post a message you must log in.