我正在尝试使用Sikul定位图像,并且对Sikuli还是陌生的。这是我编写的代码:
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) {
我得到的输出
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();
}
我遇到的另一个错误是:
Image not located in the disk.
请帮助。谢谢。
答案 0 :(得分:0)
我没有太多使用Sikuli的经验,但是我设法使用它,我认为您需要定义屏幕。以下是我点击图片的方法:
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);
}
}
希望有帮助!