how can Sikuli be used for wait for the button untill it displayed it and then click on it?

Irfanz Sheikh picture Irfanz Sheikh · Dec 15, 2012 · Viewed 17.6k times · Source

i m applying a sikuli skript on a webpage so that it when page loads it waits for the specific button when it appears it clicks it if not it wait for the certain time until button appears on the webpage..i have done the following script ..it works fine for 2 or three loops but after then the program stops and sikuli window appears ..here is my code.

while exists("img1.png"):

    click("img1.png")
    wait("img2",30*60)
    click("img2.png")
    click("window close button.png") // here it closes the 2nd popup tab after clicking on img2 then it return to its page

where he wait tor the img1 button to appear again .. so wait("img1.png",30*60) //this script works on 3 -4 iteration successfully but then it stops and sikuli window appears with no errors . thanks for your help

Answer

Kanguros picture Kanguros · Dec 16, 2012

Without any error messages it's hard to tell why your script is not working. But my best guess is that the while exists("img1.png") returns false becouse img1.png can't be found. Maybe Sikuli can't find img1.png because the page has not reloaded yet. Try to add a wait(1) at the end of the while statement.

Alternately try to use the onAppear and observe methods of the Region class: Region.observe()