To accomplish any action on image(clip) using sikuli I created below two methods:
public boolean isImagePresent(String image)
{
boolean status = false;
screen = new Screen();
try {
screen.find(image);
status = true;
} catch (FindFailed e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return status;
}
public void waitForImage(String image, int time) throws InterruptedException{
for(int i=0; i<time; i++){
if(isImagePresent(image)){
break;
}
else{
Thread.sleep(1000);
}
}
}
Call waitForImage() function into your java code as below:
waitForImage("imageName", 20);
Where "imageName" is image clip and second argument is time to wait.
public boolean isImagePresent(String image)
{
boolean status = false;
screen = new Screen();
try {
screen.find(image);
status = true;
} catch (FindFailed e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return status;
}
public void waitForImage(String image, int time) throws InterruptedException{
for(int i=0; i<time; i++){
if(isImagePresent(image)){
break;
}
else{
Thread.sleep(1000);
}
}
}
Call waitForImage() function into your java code as below:
waitForImage("imageName", 20);
Where "imageName" is image clip and second argument is time to wait.
It is awesome.....Thanks a lot....this function solved my issue so quickly
ReplyDeleteExcellent work!
ReplyDeletehi, does sikuli work on mobile apps ?? i have to test the image present on map . please guide .
ReplyDeletei have 2 windows if i want to switch from one window to another ,im using driver.switchto.window("abc"); but its not working pls anyone gide me
ReplyDelete