Like us on Facebook


September 28, 2015

isDisplayed vs isEnabled

September 28, 2015 10
In this post i will  show you the difference between isDisplayed() and isEnabled()


boolean isDisplayed()
Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
Whether or not the element is displayed

Method used to verify presence of a web element within the webpage. The method is designed to result a Boolean value with each success and failure. The method returns a “true” value if the specified web element is present on the web page and a “false” value if the web element is not present on the web page.


boolean isEnabled()
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
True if the element is enabled, false otherwise.

Reference :
Method used to verify if the web element is enabled or disabled within the webpage. Like isDisplayed() method, it is designed to result a Boolean value with each success and failure. The method returns a “true” value if the specified web element is enabled on the web page and a “false” value if the web element is not enabled (state of being disabled) on the web page

After Executing code :

Below is the Code:

September 16, 2015

Selenium Grid Extras

September 16, 2015 7
In this post i am going to explain about Selenium Grid Extras.

Selenium Grid Extras :

Simplify the management of the Selenium Grid Nodes and stabilize said nodes by cleaning up the test environment after the build has been completed.

For More information on Selenium Grid Extras you can refer to this link. 


Features of Grid Extras:
  • Ability to control individual grid nodes, following is an incomplete list of OS level tasks:
    • Killing any browser instance by name
    • Stopping any Process by PID
    • Moving mouse to specific location
    • Get Memory usage and disk statistics
  • Automatically upgrade WebDriver binaries
  • Restart node after a set number of test executions
  • Central storage of configurations for all nodes on the HUB server
  • Screenshots at the OS level
  • And much more.

Steps to Install / Configure Selenium Grid Extras:

Download Grid Extras Jar file from Here : Download Selenium-Grid-Extras

Selenium Grid Extras is a project that helps you set up and manage your local Selenium Grid. Typical instances of the Grid consists of the HUB and Nodes. The HUB is responsible for managing test sessions and assigning new session idle nodes.
Setup of Grid Extras is made to be simple, just run the packaged JAR file and point the node at the HUB location, Grid Extras will take care of the rest for you.

Hub SetUp:
1. After downloading selenium grid extras jar file, open command prompt and navigate to folder where grid extras jar file is available.
2. Type in command  java -jar

I renamed selenium grid extras jar file to SeleniumGridExtras.jar.

After starting seleniumgridextras it will prompt several questions.

What is the default Role of this computer? (1 - node | 2 - hub | 3 - hub & node)

Default Value: 1

if you want to use your machine as Hub..then you need to type 2, if you want to use your machine as hub and node then type 3.

In this case i am using it as hub  so i type in 2.

What is the HOST for the Selenium Grid Hub?
Default Value:
In my case it is default value so i just click Enter

What is the PORT for the Selenium Grid Hub?
Default Value: 4444
Press Enter port will be set to 4444

Default Value: VISTA

I left it as default

Would you like WebDriver, IEDriver and ChromeDriver to auto update (1-yes/0-no)
Default Value: 1
Press Enter --it will automatically updte your webdriver,IE and chrome drivers

Once you set all options your command prompt should look like this

Verify Grid Console and Grid Extras

type in the IP address which is shown in command prompt and output looks like this

It shows you  RAM and OS details

Now open grid console --- http://localhost:4444/grid/console

Grid Node Set Up:

Go to another machine and start seleniumgridExtras.jar

It will prompt several questions:

What is the default Role of this computer? (1 - node | 2 - hub | 3 - hub & node)

Default Value: 1
type 1 ..bcs we want to use this as node

What is the HOST for the Selenium Grid Hub?
Default Value:
type in IP address of HUB ..ex: 172.xx.xx.xx

What is the PORT for the Selenium Grid Hub?
Default Value: 4444
Press Enter port will be set to 4444

Will this node run 'Firefox' (1-yes/0-no)
Default Value: 0

Yes I want to run Firefox so i type in 1

What version of 'Firefox' is installed?
Default Value: 36

It will identify your firefox version. Press Enter

Will this node run 'InternetExplorer' (1-yes/0-no)
Default Value: 0
Yes I want to run IE so i type in 1

Similarly it will prompt questions for Chrome, Safari based on your requirement you have to choose option.

Would you like this Node to auto update browser versions? (1-yes/0-no)
Default Value: 1

press 1 if you want to auto update browser versions.

Should this Node record test runs? (1-yes/0-no)
Default Value: 1

Press Enter 

Once you set all the options it will start Grid Extras..

it should look like this....

Now you are all set to run your scripts on grid extras.

Again come back to HUB and navigate to http://localhost:4444/grid/console 
it should look like this

Now i can run scripts in FF,IE and Chrome.

The rest is have to run your webdriver script.

Below is the sample script.

Once the execution is done...Open HUB URL http://1xx.xx.xx.xx:3000/ or in HUB machine open url 

It should look like this...

You can see videos in seleniumgrid extras folder...where you seleniumgridextras jar file is available. One folder will be created with name "video_output" in that folder you can see video files.

September 8, 2015

Selenium Grid by using VisGrid

September 08, 2015 12
In this I will explain you what is selenium grid and how to setup this grid in simple way...

Selenium Grid:
Selenium-Grid allows you run your tests on different machines against different browsers in parallel. That is, running multiple tests at the same time against different machines running different browsers and operating systems. Essentially, Selenium-Grid support distributed test execution. It allows for running your tests in a distributed test execution environment


When to Use It:

Generally speaking, there’s two reasons why you might want to use Selenium-Grid.
  • To run your tests against multiple browsers, multiple versions of browser, and browsers running on different operating systems.
  • To reduce the time it takes for the test suite to complete a test pass.

Grid Set Up:

To set up grid its a bit tedious task..
1. Set up Hub
2 .Register your nodes to Hub
3. Mention max number of instances and sessions...etc etc...Everything you have to do it from command prompt...

Do we need to use boring command prompt..??
Do we have any GUI for grid?
Answer is Yes

What is the tool??

Here is Answer VisGrid

VisGrid is a GUI for Selenium Grid. You can start hub, create and attach a Selenium node very easily and quickly.

Here are details about VisGrid usage:

Steps to Download VisGrid:

Scroll down to bottom of page and Enter email id and click download.
You can see Release notes here --

After downloading, unzip
Double click on Visgrid-1.8.jar
Click Start Hub Button
Now Hub is started and 'Create Node' & 'Stop Hub' buttons are displayed

Click 'Create Node' button
Select a browser and click 'Add' button

That's it. You have created Hub and attached a node successfully
Hit http://localhost:4444/grid/console to cross check your actions

By default VisGrid-1.8 came with 2.46, if you want you can change selenium-server and drivers.

Now your Grid is configured and ready to run scripts in parallel using Selenium Grid and VisGrid.

Steps to Create Grid_Maven Project:

Create a Maven Project --- Create-sample-maven-project
Difference between normal webdriver script and Grid script is how you instantiate your browser

What is Hub:
The hub is the central point where you load your tests into.
Controlling of execution will be done from Hub
The hub is launched only on a single machine
The machine containing the hub is where the tests will be run, but you will see the browser being automated on the node.

What is Node:
Nodes are the Selenium instances that will execute the tests that you loaded on the hub.
There can be one or more nodes in a grid.
Nodes can be launched on multiple machines with different platforms and browsers.
The machines running the nodes need not be the same platform as that of the hub.

Develop Script that can run on Grid:

There are two important classes which plays major role while running scripts using Grid
DesiredCapabilites is used to set the type of browser and OS that we will automate
RemoteWebDriver is used to set which node (or machine) that our test will run against.

Here is the sample script which can run script on Grid.

Here is sample testng.xml file

Final Project you can Download from here ...


September 3, 2015

Generate XSLT reports for Webdriver scripts using ANT build.xml

September 03, 2015 4
This is continuation of my previous post Ant-with-selenium-webdriver-and-testng.html 

In previous post i explained how to integrate ant with selenium and testNG. In this post i will explain how to Generate XSLT reports using Ant.

Need of  XSLT reports:

Till now we are relying on reports generated by testNG. But those reports are not much interactive. XSLT reports are very interactive and easy to understand. Below is sample report.

Steps to Configure XSLT reports:

1. SeleniumWebdriver Project developed using ANT. If you want you can download it from here.


2. Download XSLT from here Download XSLT

Configure XSLT:

  1. Download and unzip it 
  2. Copy all jar files and place them in jar library folder in your project.
  3. Copy the testng-results.xsl from the testng-xslt folder(path: XSLT jartestng-xslt-1.1.2-mastertestng-xslt-1.1.2-mastersrcmainresources) and place in your project folder.
  4. Modify xml code in build.xml

Below is updated build.xml file. which has xslt code included.

How to Generate XLST Reports:

To generate XSLT report you need to run build.xml file and need to check the task check box (makexsltreports) then report will be generated under your project with folder Name --- XSLT_Reports---output--index.html

Below is folder path screenshot:

Below is sample report: (PASSED)

Run From Command prompt:

You can run makexsltreports task from comamnd prompt also. Here is the way to run
Navigate to projetc folder from command prompt and type in --- ant  

ant makexsltreports

I updated  code to generate failed report.

Below is failed report:

Click on Test which is under TestNG Results.
Click on Failed test case method name (testTC2()). and click on will show you details about exception.

You can download project Here ... ANT_Webdriver_TestNG_XSLT

September 2, 2015

Class EventFiringWebDriver and Interface WebDriverEventListener

September 02, 2015 4
Class EventFiringWebDriver and Interface WebDriverEventListener
In this post i will try to explain what is the use of Class EventFiringWebDriver and Interface WebDriverEventListener in selenium webdriver.

EventFiringWebDriver is a class and is used to wrap your webdriver around to throw events.

WebDriverEventListner is an interface which you have to implement to catch the webdriver events. 

EventFiringWebDriver implements WebDriver interface, meaning you will get all regular methods like findElement,get,getText etc...apart from those methods you will also get register and unregister.

Register method is used to register your implementation of WebdriverEventListner to Webdriver events.

Below programs explains you how to implement Class EventFiringWebDriver and Interface WebDriverEventListener.

Here in this example i am trying to 

1. Highlight element before performing any action and 
2. Capture screenshot after every step.

First Lets implement WebDriverEventListener interface...MyListener is class Name which implemnts WebDriverEventListener  interface.

You can get this code from My Gitrepo:


Google drive.

Experiment_WebDriverEventListener Project

package util;

import java.util.UUID;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import experiment.Facebook;

public class MyListener implements WebDriverEventListener{

 public void afterChangeValueOf(WebElement element, WebDriver driver) {
  // TODO Auto-generated method stub


 public void afterClickOn(WebElement element, WebDriver driver) {
  // TODO Auto-generated method stub


 public void afterFindBy(By by, WebElement element, WebDriver driver) {
  //this is class which will generate unique number for screenshot
  UUID sc = UUID.randomUUID();

  //Capture screenshot
   File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
   // Now you can do whatever you need to do with it, for example copy somewhere
   try {

    FileUtils.copyFile(scrFile, new File("Screenshots\\"+Facebook.screenshotFolder+"\\"+sc+".jpg"));
   } catch (IOException e) {
    // TODO Auto-generated catch block


 public void afterNavigateBack(WebDriver driver) {
  // TODO Auto-generated method stub


 public void afterNavigateForward(WebDriver driver) {
  // TODO Auto-generated method stub


 public void afterNavigateTo(String url, WebDriver driver) {
  // TODO Auto-generated method stub


 public void afterScript(String script, WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeChangeValueOf(WebElement element, WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeClickOn(WebElement element, WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeFindBy(By by, WebElement element, WebDriver driver) {

   WebElement elem = driver.findElement(by);
   // draw a border around the found element
   if (driver instanceof JavascriptExecutor) {
    ((JavascriptExecutor)driver).executeScript("arguments[0].style.border='2px solid red'", elem);
    //((JavascriptExecutor)driver).executeScript("arguments[0].setAttribute('style', arguments[1]);", elem, "color: yellow; border: 2px solid yellow;"); 


 public void beforeNavigateBack(WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeNavigateForward(WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeNavigateTo(String url, WebDriver driver) {
  // TODO Auto-generated method stub


 public void beforeScript(String script, WebDriver driver) {
  // TODO Auto-generated method stub


 public void onException(Throwable throwable, WebDriver driver) {
  // TODO Auto-generated method stub



Here is my Class which uses EventFiringWebDriver. Class Name is Facebook.

package experiment;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import util.MyListener;

public class Facebook {
 public WebDriver wdriver;
 //create a variable for EventFiringWebDriver
 public EventFiringWebDriver driver;
 //boolean value for screenshot --if you set false it will highlight element
 public static boolean screenshot=true;
 //boolean value for highlight --if you set false it will not capture screenshot
 public static boolean highlight=true;
 //date --simple date format for screenshot folder name
 public static Date dNow = new Date( );
 public static SimpleDateFormat ft = new SimpleDateFormat("ddMMyy_HHmmss");
 public static String screenshotFolder=ft.format(dNow);

 public void testFacebook() throws Exception {

 public void beforeClass() {
  //create an object for webdriver
  wdriver = new FirefoxDriver();
  //create an object for EventFiringWebDriver
  driver = new EventFiringWebDriver(wdriver);
  //this is class which implements WebDriverEventListener
  MyListener myListener = new MyListener();
  //registering EventFiringWebDriver to normal webdriver
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  /*System.setProperty("", "D:\\Jar\\chromedriver.exe");
  driver = new ChromeDriver();*/

 public void afterClass() throws Exception {


Creating a Github Repository for Selenium Webdriver Project

September 02, 2015 6
This post is regarding Creating a repository using Git and Eclipse.

  1. GitHub is a Web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features. More information about GitHub: Click Here
What is need of Version Control System?

Version Control/Source Control/Revision Control is a system remembers history of your files.

Below are some of the reasons why we use Repository. 
1. Lets assume there are 4 resources in your project and Resource 1 developed a function which is useful to other members, then he need to save that file in central location where every one can get that function.
2. Made a change to code, realized it was a mistake and wanted to revert back
3. Lost code or had a backup that was too old
4. Wanted to see the difference between two (or more) versions of your code

  • Made a change to code, realized it was a mistake and wanted to revert back?
  • Lost code or had a backup that was too old?
  • Had to maintain multiple versions of a product?
  • Wanted to see the difference between two (or more) versions of your code?
  • Wanted to prove that a particular change broke or fixed a piece of code?
  • Wanted to review the history of some code?
  • Wanted to submit a change to someone else's code?
  • Wanted to share your code, or let other people work on your code?
  • Wanted to see how much work is being done, and where, when and by whom?
  • Wanted to experiment with a new feature without interfering with working code?

Create GitHub Account:

Navigate to Join GitHub and Create an account.

By default Free account will be chosen. Click Finish Signup button.
You will get a verification email and click Verify Email button in that email.
After clicking that it will navigate you to GitHub Home Page. Where you can create repositories.

Eclipse Latest Version (At least Luna)
Sample Webdriver Project using Maven (Create-sample-maven-project.html)
GitHub Account

Steps to Create Git Repository:
1. In eclipse Right click on Project Team --Share Project.
2. Select Git and Click Next.
3. Click on Create button and Give path of local repository (F:\Gitrepo)

4. Now Enable Git related Views ... Window--Show View --Other --Git --Git repositories and Git Staging

5. Now if you observe project is moved to (F:\Gitrepo)
6. Now lets commit our changes to local repo.. Right click on project --Team---Commit
7. Enter a commit message this is a best practice and select files you want to commit. Click Commit.

8. Once you committed it will create a master under local folder.
9. Now Navigate to GitHUb and create a repository.
10. Once the repo is created copy repo URL as shown in below screenshot.

11. Now back to eclipse and Right click on remotes under Git repositories --Create Remotes
12. No Need to change name..Click OK.
13. in the next screen click Change and enter repo url and credentials.

14. Click advanced select Master from dropdown and click add spec and check save configuration check finish..
15. Click Save.
16. Expand remote under Git repositories and you can see Origin under remote folder.
17. Right click on Red arrow Under Origin and select push.

18. Changes will be pushed to repo. Check your Github repo.

This is How to create repo in Github....

Update local file and commit changes to Gitrepo:

1. Update one file in eclipse.

3. Right click on File Team --Commit and enter commit message

4. Click Commit and Push..Enter credentials changes will be pushed to repo.

Thats it..this is how to create repo and commit your changes.