Sikuli With Java For Testers
Introduction:
Sikuli is an open source tool to
automate and test graphical user interfaces (GUI) using images (screenshots).
As,
Sikuli is based on image recognition, it waits for anything to appear on screen
and, click, type etc. according to the specified identifiers. The identifiers
are specified by images. Sikuli triggers GUI interactions based on the image
visual match, the image which we have passed as the parameter along with all
methods.
For example, if there is a Flash component on
the web page with a "Next" button, an image of the "Next"
button could be captured using the Sikuli, and stored. Then with the Java code
the "Next" button could be identified and clicked. In-addition, the
core of Sikuli Script is written in Java, which means you can use Sikuli Script
as a standard JAVA library in your program.
Sikuli Can Be Useful When:
- When we are testing Legacy apps which are designed without a thought towards testability and thus ids were not specified by the developer
- When we have to be particular about UI which has lot of images and flash content on the webpage
- When we have to deal with an application like Google maps, Excel
- It can also be used to test non-browser GUI applications
Common Functions of Java I Used In Sikuli Framework
1)Absolute Path
3) Send Email Function
Prerequisite
1. Download and install sikuli from for more information visit link "http://www.sikuli.org/download.html2. Download and install java 1.6
3. Download and setup eclipse with Test NG
I have created a sikuli script in which I open notepad, type some text and save file into system.
Step by Step working
1. Create a java project in to your eclipse.
2. Add "testng.jar" and "sikuli-script.jar" to your eclipse library.
3. Create a images folder into your java project as below.
4. Get images of using Sikuli IDE and put into images folder.
5. Create a java class into src folder.
6. Import sikuli classed and create Screen class object. as below java code:
package com.test;
import org.sikuli.script.App;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;
import org.testng.annotations.Test;
public class SikuliTest {
public Screen screen;
@Test
public void tesSikuli() throws InterruptedException, FindFailed
{
//open note pad application
screen =new Screen();
App.open("notepad.exe");
Thread.sleep(2000);
//type text notepad
screen.type("images/InputFiled.png", "Testing sikuli with Test NG");
Thread.sleep(2000);
//click on file menu
screen.click("images/FileMenu.png", 20);
Thread.sleep(2000);
//click on save submenu
screen.click("images/SavesubMenu.png", 20);
Thread.sleep(2000);
//select file input field and type path
screen.click("images/FilePathInput.png", 20);
screen.type("images/FilePathInput.png", "C:\\test.txt");
Thread.sleep(2000);
//click save button
screen.click("images/SaveButton.png", 20);
Thread.sleep(2000);
}
}
7. Right click on eclipse test scripts and chose Run As > TestNG Test and click.
8. After successfully run you can see eclipse console log as below screen.
No comments:
Post a Comment