Reading Time: <15 minutes

What’s up Guys! Welcome to

Today I come up with old topic/tool but I wanted to give a try to make this interesting based on current trends. Technique is, how efficiently we can integrate Sikuli+Java Reflection/Image Object Model+ Selenium with your existing automation architecture. This technique can be customized based on your project requirement easily.


  • How to compare image/graph image visualization in existing framework.
  • In Cucumber BDD – Step definition keep growing, how to control for unnecessary steps.
  • How to implement utils function in Data driven instead of feature file
  • Integrating Sikuli in Cucumber datatable

The ideas are:

  • Implementing Sikuli in part of cucumber datatable.
  • Implementing Image Object Model which is similar like Page Object Model.
  • Implementing Java Reflection to load Image objects dynamically in run time and avoid unnecessary to create step definitions.

Getting Started:

Sikuli Overview:

To explain shortly what is Sikuli? Well, anything you see in desktop can be automated. Sikuli is useful to automate UI and Desktop application using image recognition mechanism, meaning you need to take snap and store necessary images to perform action for eg., Search button image, click button image etc., The main purpose I feel Sikuli is success to compare Visualization for eg., Image, Charts, graphs etc., with simple Sikuli API code.

Well, all tools have some PROS/CONS .


  • Can automate Desktop and UI
  • Easy and Simple use
  • Can be used to automate Graph, Charts, Flash objects, Gaming, Flash websites etc.,
  • Open Source
  • When certain situation not able to find element


  • You must store massive images to compare actual results.
  • Having Sikuli alone can’t automate enterprise or large scale application.
  • If any changes happen in image then script will fail until you change the image.
  • Sikuli doesn’t run in locked screen but possible to work around through VM machines.
  • Cannot assure all time image comparison gets passed.
  • Performance generally slow.

Automation Framework Design


Image Object Class

Image Object Model is similar kind of implementation like Page Objects Model. Idea here is storing images in specific feature based folder under resources, and create separate class for each page to load appropriate images.

public class GoogleHomePage {

    public String googleTextbox() {
        return GOOGLEPATH + "googleTextBox.png";

    public String googleSearchButton() {
        return GOOGLEPATH + "googlesearchbutton.png";

Sikuli Util:

This util has implementation of all Sikuli Methods like enter on images, click on images, double click on images, verify image exists etc.,

Note: This is base implementation, can be improved by adding more methods.

Selenium Util:

All selenium API methods.

Feature File:

How to remove unnecessary steps in feature file? Increasing more steps in feature file is hard to maintain framework level, there are some possibilities to increase duplicate step definition and redundant steps. To avoid this Java Reflection come to picture, The below highlighted data table has Java Reflection implemented which makes our task simple with Data Driven approach as well as step definition less approach.

All we need to do is, supply “Class Name” and “Method Name”

Note: This is I tried for loading/initializing image but it’s possible to implement all for better feature file as well as step definition maintenance. However, these 2 scenarios is real examples to have framework flexible and customized step definitions.


Java Reflection:

case "initializeImage":
String[] name = data.get(actionType).split("\\.");
Class<?> imageclass = Class.forName("com.automationcalling.imageobjects." + name[0]); // convert string classname to class
Object imagehomepage = imageclass.newInstance();
methodName = name[1];
Method elementImage = imagehomepage.getClass().getMethod(methodName);
initializeImage((String) elementImage.invoke(imagehomepage));

To play with this sample framework, please feel free to clone


When requirements and application functionality growing probably steps in feature file and step definition keep growing in reality which makes redundant and duplicate steps and its definition. This article explains how to main better way of maintaining feature and its step definition using Java Reflection, as well as how to integrate Sikuli part of Cucumber Data table + Maintaining image repository to avoid using more step definitions for Sikuli operation. This implementation (Using Java Reflection) is possible to implement regular reusuable methods and class for Page Factory Design Pattern or Page Object Model if your existing automation architecture has Cucumber BDD implementation.

This idea is not completely removing feature steps/step definitions rather optimized way of creating step definition without changing the flavor of BDD.

Have fun in Automation, please subscribe for more updates!.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s