0

I'm trying to use sikuli to verify if an image appears on the html page or not. Below is the code:

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();
    }

And I'm getting the following error when I run it:

[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)

I tried having the image file placed under the same folder as the java file, and also in it's separate folder (under project/images). However I'm still getting the same result. Any help would be greatly appreciated. Thanks.

JLau
  • 303
  • 2
  • 5
  • 21

2 Answers2

0

solved my own problem by following this:

http://doc.sikuli.org/faq/030-java-dev.html#how-to-use-sikuli-script-in-your-java-programs

RaiMan
  • 1,088
  • 8
  • 13
JLau
  • 303
  • 2
  • 5
  • 21
0

we resolved a similar issue - not seen on Sikuli IDE and reported from Eclipse by changing the absolute path of the file referred to in the Code: s.wait("x.png");

Screen s = new Screen();

          try {

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

here I gave absolute path for the images instead of current project folder name alone.