Test Automation with Selenium Object Bank & Cucumber JVM

This article is for the people who would like to automate their applications pragmatically with less effort. We all know, designing a framework for every project is a big deal and tiresome process. You may say, ‘I am using Page Object Model and TestNG’. It’s not just adopting certain frameworks, what matters is, how much time you’ve spent on designing the page objects. So, this article tells you how to facilitate & mitigate incommodious tasks using Selenium Object Bank and Cucumber JVM. You can consider this as a Hybrid Framework. Click here to download sample project (Cucumber with SOB).



What is Selenium Object Bank

Selenium Object Bank (SOB) is a project introduced by Automation Testing Utilities. Using this, we can reduce the little effort in creating page objects. The objectives of SOB are

  • Storing all the Objects in a central location
  • Changing Object properties without any modification on the Script
  • Readability and clear understanding of the automation steps performed by just looking into the Script
  • Minimizing the Script code by Object notation
  • Creating Robust Scripts
  • Re usability of the Objects
  • Identifying the Objects with different locators other than those provided by Web Driver (id, name, xpath, css, class, tagName)

What is Cucumber

Cucumber allows you to write feature documentation in Plain Text. You could sit with your Client or Business Analyst to write down the features to be built on your application. Proper use of this framework has a great potential to bridge the gap between business people and development people. Anyway I am not gonna illustrate every nook and cranny here. Simply saying, cucumber jvm will generate the test methods for you so that you don’t need to spend time on designing test methods again. You can surf in internet for more information on Cucumber.

How to use SOB

Selenium Object Bank is available as a Plugin for Eclipse IDE. You must follow few steps to avail the beauty of it.

Step 1. You need to download the Plugin from here and download SOB jar fromhere
Step 2. Launch Eclipse IDE, click on Help –> Install New Software

Step 3. You should see a window with ‘Add’ button. On clicking ‘Add’, you should see a pop up ‘Add to Repository‘ which allows you to add the downloaded Plugin. Just click on Local and browse the extracted zip.

Step 4. Once the Plugin directory is selected, the path is shown in the small window. Click on ‘Ok’ button, you can also give the name it’s optional.

Once it’s done, you should see ‘Selenium Object Bank Manager‘ on right clicking any class

How to use Cucumber

It’s quite simple, we need to design scenarios in features files which states the behavior of the application in plain English. Once you’re done with it, just right click on the feature file and run as ‘Cucumber Feature’ which generates test methods saying ‘You can implement missing steps with the snippets below’ in the console.

How to use Cucumber JVM with Selenium Object Bank

Once you get the test methods on running cucumber feature files, you need to create step definitions for all the scenarios. For that just create a Package named ‘com.stepDef’ and create a class of that feature. Now copy the test methods from console and paste it in the class you have created.

Right click on that class, you should see ‘Selenium Object Bank Manager‘. Just click it.

Now here comes the interesting part, you should see a control panel where you can add the page objects present in that page.

Just give proper readable object name and also Attribute (xpath) & Value (value).

From the SOB window you can see the available Objects in the left Pane
When you click on any Object from the left pane, you can see the Object details and the Element Tag type from the Properties table and the Select Box
To Add an Object, Enter a Unique Object Name in the field, Select the element tag type, enter the attribute and its value (you can add more than one locator) and click on Add button.

Once you’re done with adding page objects close the window and Refresh the Project. A package starts with ‘objects.mapper…’ and a folder ‘ObjectBank’ along with a class Has[Script Name]Objects will be generated.

It’s simple right! now you can just call the page objects wherever you require it. Since most of the work was done by Cucumber & SOB and rest will be done by us implementing few logics based on the functionality. This framework really saves huge time and makes you nonchalant. You can download sample project (Cucumber with SOB) from here.

I hope this framework can be used for automating web applications (Selenium) as well as mobile applications (Appium) too.

Credit goes to the creators of SOB and Cucumber frameworks.


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s