我正在使用 sikuli-script.jar 单击带有 Selenium WebDriver 的图像链接(使用 TestNG 框架)。当我运行我的代码 Run as TestNGSuite 或使用 ant run (从命令提示符)时,同样的工作正常。以下是我的代码: -
WebDriver driver=new FirefoxDriver();
driver.get("http://google.com");
driver.manage().window().setSize(new Dimension(1366, 768));
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
System.out.println("Title is " +driver.getTitle());
System.out.println("Browser opened");
try {
Screen s=new Screen();
Pattern image=new Pattern("D:\\LoyalityFiles\\gmail\\1476714460371.png");
s.find(image);
s.click(image);
System.out.println("clicked on gmail");
System.out.println("Title of this page is " +driver.getTitle()+" and url is " +driver.getCurrentUrl());
driver.quit();
} catch (Exception e) {
e.printStackTrace();
}
}
问题:-通过詹金斯运行此代码时,它会抛出:-
FindFailed: can not find P(D:\LoyalityFiles\gmail\1476714460371.png) S: 0.7 on the screen.
[testng] Line 1574, in file Region.java
[testng]
[testng] at org.sikuli.script.Region.handleFindFailed(Region.java:1574)
[testng] at org.sikuli.script.Region.wait(Region.java:1682)
[testng] at org.sikuli.script.Region.find(Region.java:1590)
[testng] at sikuli.ImageC.Google(ImageC.java:33)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[testng] at java.lang.reflect.Method.invoke(Method.java:606)
[testng] at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
[testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
[testng] at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
[testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
[testng] at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
[testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
[testng] at org.testng.TestRunner.privateRun(TestRunner.java:774)
[testng] at org.testng.TestRunner.run(TestRunner.java:624)
[testng] at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
[testng] at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
[testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
[testng] at org.testng.SuiteRunner.run(SuiteRunner.java:261)
[testng] at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
[testng] at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
[testng] at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
[testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
[testng] at org.testng.TestNG.run(TestNG.java:1048)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1355)
[testng] at org.testng.TestNG.main(TestNG.java:1324)
请注意:- 我将 jenkins 作为 Windows 服务运行。请建议!