Road to capture screen shot of failed Webdriver script part1

In this post I will show you how to capture screen shot of failed test using exception handling and test marked failed in report.
In below example I handle exception using try catch block and call capture screen shot function in catch section, then throws exception make test fail.

Webdriver (Selenium ) Interview Questions and answers

Question 1: What is Selenium 2.0
Answer: Webdriver is open source automation tool for web application. WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API.

Question 2: What is cost of webdriver, is this commercial or open source.
Answer: selenium  is open source and free of cost.

Difference between findElement and findElements of Webdriver

Here you will learn the difference between findElement() and findElements() function of Webdriver (Selenium).

findElement:  
1. findElement is use to locate single element and it return WebElement  object of first occurrences element on web page.
2. If element not found it will throw exception NoSuchElementException
3. Syntax: findElement(By by).

Example:
WebElement element = driver.findElement(By.id("Home"));
element.click();

findElements: 
1. findElements is use to find multiple element on webpage,  exp: as we need to count total number of row in table
2. It return List of WebElement object of all occurrences of element.
3. If element not found it will return empty List of WebElement object.
4. Syntax: List element = findElenets(By by)

Example:
List {WebElement} element = driver.findElement(By.xpath("//table/tr"));
int size = element.size();


Git repository commands

In this post you will learn Git commands with example.
1. git clone: This command clone existing repository 

Road to automate Html5 video with Webdriver (Selenium)

In this post I will show you how to automate HTML5 video.  To automate this we will use java scripts function to control video. So here we use “document.getElementById("Video ID")” , it return the HTML 5 video object. Using this object we can simulate video. Following are some java script function to handle video.
1. Play video
            document.getElementById("Video ID").play();  

Configuration of mobile user agent with webdriver

I this posts you will learn how to execute webdriver test script on browser using mobile user agent.

Installation:
1. Install user agent in Firfox from link: User Agent
2. Install user agent in Google chrome from link: User Agent

Road to override TestNg listener methods

In this post I will show you how to create custom testng listener  class and override its methods.
Create java class like I created below “MyListner” and inherit “TestListenerAdapter” testing class.

package com.test;

import org.testng.ITestResult;
import org.testng.TestListenerAdapter;

public class MyListner extends TestListenerAdapter {
       
     @Override
     public void onTestFailure(ITestResult result) {
        System.out.println(result.getName() + " Test method failed\n");
     }

     @Override
     public void onTestSkipped(ITestResult result) {
        System.out.println(result.getName() + " Test method skipped\n");
     }

     @Override
     public void onTestSuccess(ITestResult result) {
        System.out.println(result.getName() + " Test method success\n");
     } 
 

Road to setup and configure Git repository.

In this post I will show you how to setup Git repository on windows machine.
Installation:
1 Download git exec file from link: click
2 Click on downloaded git exe file for installation.

Road To NUnit setup, test execution with a simple test script

NUnit:
Nunit is an open source unit testing framework for all .Net language

Setup NUnit: 
Download nunit exe from link: download
Install downloaded exe in your machine. your nunit GUI look like below screen when you open nunit