May 15, 2015

Running Webdriver with Firebug and Selenium IDE addons


When you run webdriver script it will not have IDE and Firebug addons. How to Run Firefox with  Firebug and Selenium IDE addons??


Download Firebug xpi and Selenium IDE file from mozilla and start the firefox profile.

Below is the solution for that:


Download firebug.xpi and selenium-ide.xpi.

Firefox : 33
firebug version 2.0.9 (Get it from here : and download 2.0.9
Selenium IDe version : 2.9.0  ( Download selenium IDE.xpi and extract it. From extracted files you have to use selenium-ide.xpi.


Once the browser is launched then you can see Firebug and Selenium IDE are available in your browser. It will help you in debugging your scripts..

Below is the code:

March 12, 2015

Scroll And Print All Products Name From A Web Page

Now a days most of the e-commerce web applications are using a concept called Lazy loading.

Lazy Loading: Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed.

Example for lazy loading:

1. Open
2. Search for Mobiles
3. If you scrolldown the page more results will be loaded ...this concept is called lazy loading...

Now the question is to scroll down till you find all the products in that page and get names of all the products.

Here is the script :

Scroll And Print All Items Name From A Web Page

The above script will cover how to scroll page and get the product details..

December 8, 2014

Working with Multiple windows using selenium webdriver

In this blog post i am trying to address easiest way to handle multiple windows.

Selenium webdriver has mechanism to identify windows.

getWindowHandle() ---
Return an opaque handle to this window that uniquely identifies it within this driver instance. This can be used to switch to this window at a later date.

Return a set of window handles which can be used to iterate over all open windows of this WebDriver instance by passing them to switchTo().WebDriver.Options.window()

In this example script will perform some actions on main window, after clicking a link it will open a new window and webdriver will switch to child window and perform actions. Once the actions are done on child window it will close child window and switch back to parent window.

Here is the code..

November 30, 2014

Perform Type Action using Java script in Text field

To type in a text field/text box  we use sendKeys command. But some times sendKeys will not work some of the text fields. In those situations one of the alternative is using JavaScript. We can use Java script to type in text field.

In below example I used JavaScript to type in text field.
Below is syntax: 
((JavascriptExecutor) driver).executeScript("arguments[0].value = 'some text';",driver.findElement(By.XPath('your xpath')))

July 17, 2014

GEB -- Introduction

These days I am working on a new autoamtion tool called GEB( GEB  is browser autoamtion tool which allows you to use Webdirver, jquery, POM and Groovy

Geb is built on top of the WebDriver browser automation library.

WebDriver utilizes native browser drivers to perform its automation. This is an important distinction for purposes of web testing—using Geb and WebDriver gives you the assurance that your application is behaving correctly in the browsers you test it on. It also provides access to browser commands that are simply inaccessible without native driver support.

Below are the advantages of GEB:

  1. Power of WebDriver
  2. Elegance of jQuery content selection
  3. Robustness of Page Object modeling
  4. Expressiveness of the Groovy language
Geb provides first class support and integration with common testing frameworks and build tools, including JUnit, Spock, Grails, Maven and Gradle.

If you want to write Elegant and powerful test cases then use 3GS
Spock  -- GEB Shines with Spock.

May 19, 2014

Download file using Selenium WebDriver by using Firefox Profile

This post will explain how to download files using selenium webdriver.

We need to create a firefox profile and set  preferences for that profile to save the file in desired location without showing the download or save to window

Below is the code:

March 3, 2014

Uploading a file using AutoIt

As we all know, Selenium will not support window based elements. To upload/download we need to use some third party tools.

Below post explains how to upload a file from local drive using AutoIt.

(This code is to select a file from window after clicking on browse button from web page, After this we have click on upload button from web page)

WinWaitActive("File Upload")

Write this code in Notepad and save the file as “Upload.au3”
Right Clicked on the created file “Upload.au3” and click on Compile Script.
You will get “Upload.exe” file

Call this file in Selenium script or in RFT script as below:

Process proc = Runtime.getRuntime().exec("C:\\Temp\\ Upload.exe");

Sample Selenium Code using AutoIt upload:

public class Upload {
public WebDriver driver;

public void setUp() throws Exception {
driver= new FirefoxDriver();
public void testTestScenario1() throws Exception
Process proc = Runtime.getRuntime().exec("C:\\Temp\\Upload.exe");
driver.findElement(By.xpath("//input[@title='Upload file']")).click();

public void tearDown() throws Exception {

March 2, 2014

Cross BrowserTesting using Selenium Webdriver and TestNG

This is an attempt to explain the feature of selenium webdriver and TestNG.

Generally we will run a single test case or script at a time. If you want to run  a single test on different browsers it is possible with selenium webdriver and TestNG. Test will be executed parallel in two browsers.

Lets we can achieve this


Sample Script:
Create a sample webdriver script using TestNG and in that script define a parameter using @Parameter annotation.

Below is the sample script:

Create TestNG:
Create a testNG.xml file to run your script. Parameter value we can pass it from here.

Below is the sample TestNG.xml file

Run your TestNG.xml file and three browsers will open and script will run on 3 browsers parallel.

February 25, 2014

Screenshot on Failure using Selenium WebDriver

Below post explains you how to capture screenshot when scripts fails using Selenium WebDriver.

In this script I used simple try --Catch and Finally blocks..if any error occurs in try block control will go to catch block.

In Catch block i have written code for capturing screenshot and flag is set to true.

If the flag is true then finally block statement will be executed.

In Finally block  I have written exception that will raise an exception so that you can see the results if the script as failure. 

Below is the code.....

January 4, 2014

New Features in Selenium IDE (2.5.0)

I Just noticed on 2nd Jan that a new version of selenium is released. I Just had a glance at release notes there are 3 enhancements and few fixes to existing issues.

But today when I open selenium IDE I saw the enhancements..they are really useful...

Below is Release Notes for 2.5.0

I would like to talk about a new Enhancement:

1. Select an element for a command by clicking on the element in the browser window

This is a new feature added to selenium IDE.

They added new Button Select in the Target field.

How it works:

Select a row in selenium IDE test case Pane
Click on select and move your cursor to the element which you want to locate.

In below example i would like to find locator for "Search Selenium:"

It will automatically identify the xpath or CSS or any other appropriate way to find locator...

Try this feature this is really awesome feature from Selenium.

2. Start playing a test suite from any test case (Using right click menu)

If you already have a test suite in place (Ex: A test suite with  5 test cases) and you want to run from 2nd test case.  The newly added feature supports those kind of requirement.

Just you need to right click on the specific test case in test suite and select Paly Test suite from here. Execution of Test Suite starts from that particular test case.

See below screenshot for more details

3. Add a new test case using a keyboard shortcut (ctrl-N or cmd+N) 

From selenium IDE you can a new test case by using keyboard shrotcut CTRL+N..It will automatically add new test case in selenium IDE.

Hope all these feature are very helpful for selenium IDE users...