How to integrate Sikuli scripts into Selenium?

SeleniumAutomation TestingTesting Tools

We can integrate Sikuli scripts into Selenium webdriver. Sikuli is an automation tool which is open-source. It has the feature to capture the images on the elements as well as perform operations on them.

Some of the advantages of Sikuli are −

• Desktop or Windows applications can be automated.

• Can be used for flash testing.

• Can be used on platforms like mobile, Mac, and Linux.

• It is based on image recognition technique.

• Can be easily integrated with Selenium.

Click on the jar to download it (which can be used for Java environments) and save it in a location.

Add the jar to the Java project in Eclipse IDE. Right−click on the project and select Properties. Then click on Java Build Path. Go to the Java Build Path tab. Click on Libraries. Then click on Add External JARs. Browse and add the Sikuli jar that we downloaded. Finally, click on Apply and Close.

Capture the image of the edit box on which we will enter Selenium with the help of Sikuli and save it in a location.

Example

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
public class SikuliIntegrate{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",       "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.tutorialspoint.com/index.htm");
// Screen class to access Sikuli methods
Screen s = new Screen();
//object of Pattern to specify image path
Pattern e = new Pattern("C:\\Users\\ghs6kor\\Image.png");
}