Showing posts with label Sikuli. Show all posts
Showing posts with label Sikuli. Show all posts

Road to handle file download popup in webdriver using Sikuli

In this post I will show you how to integrate webdriver test script with Sikuli automation tool to handle window popup utility like file download and upload etc.
Here I take example of a file download window popup utility, which we can not handle by using webdriver functions. Some people use different-2 automation tool like AutoIt, java Robot class to handle this.
Here is an example of webdriver sikuli integration to handle below selenium jar file download window popup utility.

Road to clear input filed using sikuli java

In this post in am going to explain, how to clear input fields value using sikuli with java. As Sikuli does not provide any function to clear input field.
To clear input fields value, I use sikuli and java Robot class. First I click on input field using sikuli click() function then I use java Robot class to clear input filed. Below is code.

Robot robot = new Robot();

robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_BACK_SLASH);

Using above approach and code,  I clear any input field with sikuli.


Sikuli Firefox Webdriver

Sikuli launched new API for java based programming language frameworks. This API provide image based GUI automation.  The new java library API has re-designed  and included several new functions that were not available in original sikuli script. Such as the ability match color. Handle events and fund geometric patterns such as rectangular button.  It can be integrated with maven build.

Requirements
  1. Java Runtime Environment(JRL) or Java Development Kit (JDK) version 1.6 or newer.
  2. Apache maven version 2.0.10 or newer if you want to build it from maven.
Supported Platform:
  1. Windows 7 (64/32 bits) 
  2. Mac OS X(64 bits)
  3. Linux (64 bits).

How to search image (locator) using sikuli

Some time we are getting that image are not displayed on screen which is captured by sikuli at run time.

Such as we open a www.google.com on browser search a text like "testing" and click on searched button we observed that we need to scroll down to click on next button which is at footer. If I used direct sikuli click command to click on next button we will get exception because image not visible on page. I am using below approach to click on next button

Sikuli With Test NG framework

Prerequisite

1. Download and install sikuli from for more information visit link "http://www.sikuli.org/download.html
2. 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.

About Sikuli

  1. Sikuli is an open-source research project originally started at the User Interface Design Group at MIT. 
  2. Sikuli Script automates anything you see on the screen. 
  3. It uses image recognition to identify and control GUI components. 
  4. It is useful when there is no easy access to a GUI's internal or source code.
  5. By Sikuli script uses Python as the scripting language. Also Sikuli script's  features supported in your Java program language.

How to wait image (clip) before perform any sikuli action

To accomplish any action on image(clip) using sikuli I created below two methods:

public boolean isImagePresent(String image)
    {
        boolean status = false;
        screen = new Screen();
        try {
            screen.find(image);
            status = true;
        } catch (FindFailed e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return status;
    }   

How to capture images using Sikuli?

Prerequisite:

1. Download and install Sikuli from for more information visit link "http://www.sikuli.org/download.html
2. Download and install java 1.6.

Steps to  capture images:

1. Open Sikuli IDE your screen should be as below screen: