0
votes

I am trying to locate an image using Sikul and I am very new to Sikuli. Here is the code that I have written:

Try{

Pattern pattern = new Pattern("Imgs\\search1.PNG");
        Match m = s.find(pattern.similar(50));
        System.out.println(m);
        s.click(m);}

 catch (FindFailed e) {
        System.out.println ("Image not matched");
        Reporter.log("No domain chosen<br>");
        //ScreenShot.screenShot(testName);
        Assert.fail("Domain not selected");
        e.printStackTrace();
    } catch (InterruptedException e) {

The output I am getting as

  catch (FindFailed e) {
        System.out.println ("Image not matched");
        Reporter.log("No domain chosen<br>");
        //ScreenShot.screenShot(testName);
        Assert.fail("Domain not selected");
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

Another error I got is:

Image not located in the disk.

Kindly help. Thanks.

1

1 Answers

0
votes

I don't have to much experience using Sikuli but i managed to work with it, I think that you need to define the screen. Below is my method to click on image:

public void click(String imgPath) {
    Screen s = new Screen(0);
    try {
        s.wait(imgPath, timeOut);
        s.click(imgPath);
    } catch (Exception e) {
        Log.severe("Cannot find image element " + imgPath);
    }
}

Hope it helps!