Our Blog

We always make sure you get the latest updates from devEngineering therefore we have crafted a well organized blog to share what we are planning for you.

How to integrate Sikuli script with Selenium Webdriver

Sikuli is a robust and powerful tool to automate and tests user interfaces screenshots. The core of Sikuli Script is written in Java, which means you can use Sikuli Script as a standard JAVA library in your program. This article lets you know how to do that. Sikuli is a robust and powerful tool to automate and tests user interfaces screenshots. The core of Sikuli Script is written in Java, which means you can use Sikuli Script as a standard JAVA library in your program. This article lets you know how to do that.

1. Download and install Sikuli using the self-extracting installer(http://www.sikuli.org/download.html).
Note: Only 32-bit version is provided for using as a standard JAVA library. But SIKULI IDE could run on both 32-bit and 64-bit Windows systems.

2. Create new Java project (use Eclipse as an example):

3. Fill project name and click Finish:

4. Create new class:

5. Fill class name and click Finish:

6. Include sikuli-script.jar, selenium-server-standalone-2.25.0.jar, selenium-java-2.25.0.jar in the CLASSPATH of your Java project. 
Get sikuli-script.jar from your Sikuli IDE installation path.

Sikuli Script is packed in a JAR file - sikuli-script.jar. Depending on the operating system you use, you can find the sikuli-script.jar in according places.

Windows, Linux: Sikuli-IDE/sikuli-script.jar
Mac OS X: Sikuli-IDE.app/Contents/Resources/Java/sikuli-script.jar

After adding sikuli-script.jar, selenium-server-standalone-2.25.0.jar, selenium-java-2.25.0.jar as a libraries into your project, the project hierarchy should look like this:

After click OK:

7. After configuring in build path, create and initialize an instance of Screen object.

SIKULI + SELENIUM WEBDRIVER

 

import org.junit.Test;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.sikuli.script.App;

import org.sikuli.script.FindFailed;

import org.sikuli.script.Pattern;

import org.sikuli.script.Screen;



public class sikuliFirstTest {



@Test

public void functionName() throws FindFailed {

  

// Create a new instance of the Firefox driver

WebDriver driver = new FirefoxDriver();



// And now use this to visit Google

driver.get("http://www.google.com");



//Create and initialize an instance of Screen object   

Screen screen = new Screen();



//Add image path  

Pattern image = new Pattern("C:\\searchButton.png");

   

//Wait 10ms for image 

screen.wait(image, 10);

   

//Click on the image

screen.click(image);

  }

}

 

Here example using SIKULI without Selenium WebDriver:

 

import org.junit.Test;

import org.sikuli.script.App;

import org.sikuli.script.FindFailed;

import org.sikuli.script.Pattern;

import org.sikuli.script.Screen;



public class sikuliFirstTest {



@Test

public void functionName() throws FindFailed {



//Open FireFox application with google home page   

App firefox = App.open("c:\\Program Files\\MozillaFirefox\\firefox.exe");



//Create and initialize an instance of Screen object   

Screen screen = new Screen();



//Add image path  

Pattern image = new Pattern("C:\\searchButton.png");

   

//Wait 10ms for image 

screen.wait(image, 10);

   

//Click on the image

screen.click(image);



//Close firefox  

firefox.close();

  }

}