Wednesday, June 17, 2015

Sikuli + Eclipse + java

How to execute sikuli script using Eclipse + java?

1. Download sikuli-setup.jar

2. Execute in cmd prompt "java -jar sikuli-setup.jar" file. It will generate runSetup.cmd in the same folder.

3. Execute it via cmd prompt.

4. It will lauch a window, choose the options "Download for IDE, eclipse" and for "windows, mac"

5. It will download sikuli-java.jar file.

6. Now open the eclipse, create a package -> create a project -> Add TestNG library and Sikuli-java.jar.

7. Save and reboot the pc (It requires a logout and login to activate)

8. Lauch eclipse and create a TestNG Class and write your code.(Note:- TestNG installation for eclipse is not covered here)

Sample code:

package sample_sikuli;

import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import org.testng.annotations.Test;

public class NewTest {
Screen s = new Screen();
  @Test
  public void Sample() {
 try {
s.click("C:/Users/USER/Desktop/1.png");
s.click("C:/Users/USER/Desktop/2.png");
s.click("C:/Users/USER/Desktop/3.png");
s.type("notepad.exe");
} catch (FindFailed e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
  }
}




No comments:

Post a Comment