Thursday, 17 October 2013

Sikuli Integration | Selenium

Sikuli locate anything based on image recognition technique; tool mainly used for recognizing the Canvas UI, browser pop ups, Flash Contents, and Java Applets.

Set Sikuli Environment

1| Download Sikuli-IDE
2| Unzip the folder under C:\Program Files\
3| Create a new System Variable under 'Environment Variables'.
Value: C:\Program Files\Sikuli-IDE
4| Add Sikuli path under the variable name, 'Path'
Variable value: C:\Program Files\Sikuli-IDE\libs
5| If this is not helping, then go to Eclipse,
Right click on Project > Run As > Run Configurations... > (x)= Arguments
VM arguments:
-Dsikuli.Home="C:\Program Files\Sikuli-IDE"

Configure Sikuli in Eclipse

6| Get sikuli-script.jar from your Sikuli IDE installation path, C:\Program Files\Sikuli-IDE
7| Add sikuli-script.jar into buildpath
8| Create a new folder, "imgs" inside project
9| Take screenshot, optimize them and place it inside the folder, "imgs"

import org.sikuli.script.*;
public static Screen sikuliObject = new Screen();

public void test01() throws Exception, FindFailed {
try{"C:\\workspace\\project\\imgs\\1.png", 0); //Clicking an image
sikuliObject.type("C:\\workspace\\project\\imgs\\search.png", "hello"); //Inserting values into a text field
}catch(FindFailed e){