Sikuli + Webdriver:获取错误 - x.png看起来像一个文件,但在磁盘上找不到。假设它是文本

时间:2012-09-05 17:27:03

标签: java webdriver sikuli

我正在尝试使用sikuli来验证图片是否出现在html页面上。以下是代码:

public void verifyimage() {
    Screen s = new Screen();
    WebDriver driver = new FirefoxDriver ();
    driver.get("http://testpage.com/");
    WebElement id = driver.findElement(By.id("input_id"));
    id.sendKeys("123");
    WebElement type = driver.findElement(By.id("input_text"));
    type.sendKeys("Text");
    WebElement submitBtn = driver.findElement(By.cssSelector("input[type='submit']"));
    submitBtn.click();
    try {
        s.wait("x.png");
    }
    catch  (FindFailed e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

我运行时遇到以下错误:

[info] Sikuli vision engine loaded.
[error] x.png looks like a file, but can't be found on the disk. Assume it's text.
[info] Text Recognizer inited.
[error] x.png looks like a file, but can't be found on the disk. Assume it's text.
FindFailed: can not find x.png on the screen.
Line ?, in File ?
at org.sikuli.script.Region.handleFindFailed(Region.java:420)
at org.sikuli.script.Region.wait(Region.java:511)
at org.sikuli.script.Region.wait(Region.java:478)
at com.pictela.runScriptTest.testScript300x250(runScriptTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1122)
at org.testng.TestNG.run(TestNG.java:1030)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

我尝试将图像文件放在与java文件相同的文件夹下,也放在单独的文件夹中(在项目/图像下)。但是我仍然得到相同的结果。任何帮助将不胜感激。感谢。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

我们解决了类似的问题 - 在Sikuli IDE上看不到,并通过更改代码中引用的文件的绝对路径从Eclipse报告:  s.wait(" x.png&#34);

屏幕s =新屏幕();

          try {

                 System.out.println("Inside Try block");
                 s.doubleClick("D:\\User\\Eclipse-Sikuli\\Wors-Space\\My_Screen\\Images\\TELTGBY7l.png");

这里我给出了图像的绝对路径,而不是单独的当前项目文件夹名称。