0
votes

I have recorded my test using the GUI desktop application, HAVE SIKULI CLICK A FLASH BUTTON.

Now I would like to use my sikuli script in Java as per below:

import org.sikuli.script.*;

public class TestSikuli {

public static void main(String[] args) {
    Screen s = new Screen();
    try{

         s.wait("imgs/ViewPlaylist.png");
          s.click("imgs/ViewPlaylist.png", 0);

           s.type(null, "hello world\n", 0);
    }
    catch(FindFailed e){
            e.printStackTrace();
    }

}

But the program is not running or displaying any output.

Could u plz look into the code and make my Java/Sikuli script run.

Thanks!

3
Hmm...that's funny, I think it should output some stuff regardless of whether the automation worked or not. How did you run the program from the command line? Also, good idea to put in print statements under try block to know that code at least is being executed. - David
Are you using Selenium for your automation? - Curtis Miller

3 Answers

1
votes

I believe you must have gone thru' this by now, but double check if you have followed all steps listed here -

http://sikuli.org/wiki/How%20to%20use%20Sikuli%20Script%20in%20your%20JAVA%20programs OR http://sikuli.org/docx/faq/030-java-dev.html

If yes, then provide more info on whether you got any problem in performing any of these steps?

0
votes

private void click(String image) throws FindFailed{

Screen screen = new Screen();

Pattern pattern = new Pattern(image).similar((float) 0.7);

if(screen.find(pattern)!=null){ 
    screen.mouseMove(pattern); 
    screen.click(pattern); 
}
}

Provide the image URL (locally or on the web), and this method should do the trick. It moves the mouse to the specified image on the screen, and clicks on it...

0
votes

Try this

import org.sikuli.script.*;
import org.sikuli.basics.ImageLocator;
 public class TestSikuli {

public static void main(String[] args) {
Screen s = new Screen();
try{
  ImageLocator.setBundlePath("path to img directory");
     s.wait("ViewPlaylist.png");
      s.click("ViewPlaylist.png");

       s.type("hello world\n");
}
catch(FindFailed e){
        e.printStackTrace();
}

}