Thursday, 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.

Monday, 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:

Monday, 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 {

Sunday, 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.

Tuesday, 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.....