Skip to main content

Sikuli installation and integration with Web driver

Sikuli: Sikuli automates anything you see on the screen. It uses image recognition to identify and control GUI components. It is useful when there is no easy access to a GUI’s internal or source code.
For Installation of Sikuli and its Integration with Selenium Webdriver follow the steps given below:
Sikuli Installation
Step : 1  Download sikuli-setup.jar
Step 2: Go to this path and downlaod https://launchpad.net/sikuli/+download
Step 3 : sikuli-setup.jar
Step 4: Now open the command Window go to folder where this jar file is present
C:/<path to the jar file> and then type runSetup.cmd  (note no spaces between runSetUp.cmd)incommandprompt
Step 5 : the a pop-up will open saying “Please read carefully before proceeding” click “OK”
Step 6: Sikuli Setup window will open select first 3 checkboxes and click on “Setup Now” then click “Yes”
Step 7 : Wait for completely Sikuli-ide-1.0.1.jar(12MB file) file to download (will take some time(around 5-10 minutes))
Step 8: Then Sikuli IDE will start automatically (DONE)
Integration with Selenium Webdriver
1.Add the following jar files to the project in which you want to integrate Sikuli tool.
i.Sikuli-api-1.0.2-standalone.jar
ii.Sikuli-webdriver-1.0.2-standalone.jar
iii.Selenium-server-standalone-2.33.0.jar
iv.selenium-java-2.25.0.jar
2.Take the image of the object on which you want to perform operations like click,type,etc.
Here is an e.g to click on a flash button.
Screen screen = new Screen();
Pattern image = new Pattern("path to flash button image");
screen.click(image);
3.After placing this code you will see some errors as libraries are not imported. Just mouse over where errors are showing and include those libraries which eclipse is suggesting.Those libraries are below:
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.sikuli.script.FindFailed; 
4.Now run the code and you are good to go!

Example:

package demoSikuli;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
public class demoSikul {
public static void main(String[] args) throws FindFailed, InterruptedException {
// We have to create Screen class object to access method
Screen screen = new Screen();
// Create object of Pattern class and specify the images path
Pattern image = new Pattern("C:\\gmail.PNG");
Pattern image1 = new Pattern("C:\\images\\uname.PNG");
Pattern image2 = new Pattern("C:\\images\\password.PNG");
Pattern image3 = new Pattern("C:\\images\\click.PNG");
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.google.com");
screen.wait(image, 10);
// using screen object we can call click method which will accept image path and will perform //action
// This will click on gmail image on google home page
screen.click(image);
// using screen object we can call type  method which will accept image path and content which //we have to type and will perform action.
// This  will type on username field
screen.type(image1, "mukeshotwani@gmail.com");
//This will type of password field
screen.type(image2, "password1");
// This will click on login button
screen.click(image3);
}
}

Comments

Popular posts from this blog

Eclipse New Maven Project: Could not resolve archetype

Close Eclipse Delete repository folder (you can find it in C:\Users{your user}.m2) Open Eclipse again. It will install maven repository automatically down v Open Window > Preferences Open Maven > Archetypes Click 'Add Remote Catalog' and add the following: Catalog File:  http://repo1.maven.org/maven2/archetype-catalog.xml Description: maven catalog

Class 1 Java introduction

What is Java Java is a  programming language  and a  platform . Java is a high level, robust, secured and object-oriented programming language. Platform : Any hardware or software environment in which a program runs, is known as a platform. Since Java has its own run time environment (JRE) and API, it is called platform. Features of Java The Java Features given below are simple and easy to understand. Simple Object-Oriented Portable Platform independent Secured Object-oriented Java is Object-oriented programming language. Everything in Java is an object. Object-oriented means we organize our software as a combination of different types of objects that incorporates both data and behavior. Basic concepts of Oops are: Object Class Inheritance Polymorphism Abstraction Encapsulation Variable Variable  is name of  reserved area allocated in memory . In other words, it is a  name of memory location . It is a...

Configure Maven Project in to Jenkins and Run

As we all know, maven is a build / project management tool, based on the concept of a project object model (POM) which contains every information about your project. Maven allows a project to build using its project object model to manage builds, dependencies, releases and documentation which are all managed from the pom.xml file. Maven defines a standard way to build the projects, test, and deploy project artifacts. It provides a framework that enables easy reuse of common build logic for all projects following Maven's standards. We discussed  maven in detail  earlier here and hope you have  configured maven . First lets Create a simple maven project in Jenkins Step 1:-  Click New Items on the left menu ->Enter Project Name in “Item name” field -> Select Maven Project ->Click OK Step 2:-  Provide the job description Step 3:-  In Source Code Management, Jenkins supports CVS and Subversion out of the box, with built-in support for...