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.

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.


16 comments:

  1. This is just awesome and very needed post for sikuli testng integration.

    ReplyDelete
  2. Hello, could you provide some details about how to add Step 2 (Add "testng.jar" and "sikuli-script.jar" to your eclipse library)?

    I use Mac, and I cannot find "sikuli-script.jar". It should be here: SikuliX-IDE/Content/Resources/. But it isn't. I found next information here
    https://github.com/RaiMan/SikuliX-IDE/wiki/Release-Notes-IDE :
    "You no longer need an extra sikuli-script.jar if you have the MacApp or sikuli-ide.jar".

    Question: Should I add sikuli-ide.jar instead of sikuli-script.jar ?

    ReplyDelete
    Replies
    1. Download "sikuli-script.jar" file from link: http://www.sikuli.org/download.html
      To add this jar file in eclipse follow below steps:
      1. Right click on project>> Build Path>> Configure Build Path..
      2. Click on libraries of opened window
      3. Click "Add External Jar" button
      4. Navigate "sikuli-script.jar" folder and select same jar file click "Open" button

      Delete
  3. Could u tel me how does sikuli can be integrated on ios side.

    ReplyDelete
  4. Awesome Post. However, need following info:

    I am using Mac and have download latest SikuliX-1.1.0-Beta1 and couldn't find "sikuli-script.jar" file.

    Please suggest?

    ReplyDelete
    Replies
    1. I don't know how you are not getting I download Sikuli-X-1.0rc3 (r905)-win32.exe and after installation you will get "sikuli-script.jar" under installed directory

      Delete
  5. Same issue with me .. I am not able to get "sikuli-script.jar" anywhere.
    Guys please share a link where we will get above mentioned jar.

    ReplyDelete
    Replies
    1. After installation sikuli you will get jar file into installed folder.

      Delete
  6. Hi,
    I have created a project and i configured Jar file but i am getting below ERROR

    "Screen cannot be resolved to a type"

    ReplyDelete
    Replies
    1. Hi Brahma, you should add sikuli jar file in your eclipse environments

      Delete
  7. Please tell me how to add images as mentioned in Step4. I am using Eclipse+SikuliAPI+Java

    ReplyDelete
  8. Please tell me how to add images as mentioned in Step4. I am using Eclipse+SikuliAPI+Java

    ReplyDelete
  9. I mean from where to get those images mentioned in step 4 ?

    ReplyDelete
    Replies
    1. You can capture images of element using Skuli IDE or can capture image using manually

      Delete
  10. Hi, what is the script for using sikuli on eclipse along with appium for mobile apps and games..kindly let me know... i am using genymotion emulator

    ReplyDelete

Leave your comments, queries, suggestion I will try to provide solution