我正在使用sikuli-script.jar点击图像链接Selenium WebDriver(使用TestNG框架)。当我运行我的代码运行为TestNGSuite或使用ant运行(从命令提示符)时,同样正常工作。 以下是我的代码: -
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();
}
}
问题: - 当通过jenkins运行此代码时,它会抛出: -
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服务。请建议!!
答案 0 :(得分:0)
SikuliX在3秒内无法在屏幕上找到您的模式(默认值Settings.AutoWaitTimeout
)并抛出FindFailed
异常。尝试提升Settings.AutoWaitTimeout
或实施自己的智能服务员,而不是screen.find()