Test case Template 

By Pavandeep Puddupakkam on February 26, 2015 | Uncategorized | A comment?

Scroll to the bottom of the webpage using Selenium Webdriver 

Here is the code that you can use to scroll to the bottom of the webpage when automating your testing using Selenium Webdriver

Actions actions = new Actions(driver);

By Pavandeep Puddupakkam on November 12, 2014 | Java, WebDriver | A comment?

Installing and running Protractor AngularJS with Jasmine Webdriver and Astrolabe 

Installing and running Protractor AngularJS with Jasmine Webdriver and Astrolabe

Before you start anythink you will have to first install NodeJS.

You can download and install NodeJS. http://nodejs.org/download/. After installation make sure its path is configured correctly, so that command execution can find Node.

Once you have installed NodeJS open the command prompt and type in the following command to install protractor globally.

npm install –g protractor

Now create a new folder called Protractor and install Protractor under c:\Protractor

npm install protractor

Once you have installed Protractor verify the installation by typing the following command

Protractor –version

The Protractor version that I have installed is Version 0.15.0

Next install jasmine-node. Use the following command:

npm install jasmine-node -g

install webdriver-manager. Use the following command:

npm install -g webdriver-manager

Download selenium server. Use the following command:

webdriver-manager update

Start the selenium server. Use the following command:

webdriver-manager start

Download chromedriver and save the file on your local


Add the location of chromedriver.exe in the Environment Variables PATH
The variable name should be PATH and not path.

Install Astrolabe (Astrolabe is an extension for protractor that adds page objects to your functional/e2e tests.)
npm install astrolabe

Create a folder called TestCases under Protractor

Create the following files


var Page = require('astrolabe').Page;

module.exports = Page.create({

url: { value: 'http://www.yourwebsite.com' },

username: { get: function() { return this.findElement(this.by.name('username')); } },
password: { get: function() { return this.findElement(this.by.name('password')); } },
submit: { get: function() { return this.findElement(this.by.xpath("//button[.='Log in']")); } },
searchIdentifier: { get: function() { return this.findElement(this.by.model('search.identifier')); } },
searchName: { get: function() { return this.findElement(this.by.model('search.name')); } },
// Adds a logIn method to the page object.
logIn: { value: function(username, password) {

var page = this;




} },
selectLink:{ value: function (linkName)
var returnedObject = "//option[contains(text(),'"+linkName+"')]";
return returnedObject;


describe('When the username and password is entered', function() {
var cf = require('./commonFunction');
it('The user should be logged in', function() {
cf.logIn('username','password'); // username and password values
it('Element should be displayed', function() {
it('the user will be able to click on the link', function() {
element(by.xpath(cf.selectLink('LINK'))).click(); // Link value
cf.searchName.sendKeys("NAME"); // Name value


exports.config = {

//The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',

//Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'

specs: ['clickALink.js'],

//Options to be passed to Jasmine-node.
jasmineNodeOpts: {
onComplete: null,
isVerbose: false,
showColors: true,
includeStackTrace: true

To to the folder c:\Protractor\TestCases and run the following command to execute the test

protractor conf.js

Useful links



By Pavandeep Puddupakkam on May 28, 2014 | Protractor | A comment?
Tags: , , ,

How to take the Screen shot in Selenium Grid 

Here is the code that you can use to take the screen shot when running the script using Selenium Grid or Remote machine

public void takeScreenshot() throws IOException {
Random rand = new Random();
int num = rand.nextInt(150);
File scrFile = null;
Integer numNoRange = rand.nextInt();
WebDriver underlyingDriver = driver.getWrappedDriver();
if (browser.contains("Remote")) {
try {
WebDriver augmentedDriver = new Augmenter().augment(underlyingDriver);
scrFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
String filename = numNoRange.toString();
copyFile(scrFile, new File("location were you want the file to be saved" + filename + ".png")); //Change location were you want the file to be saved
} catch (Exception n) {
LOGGER.warn("Failed to take screen shot of remote browser");
if (scrFile == null) {
try {
scrFile = ((TakesScreenshot) underlyingDriver).getScreenshotAs(OutputType.FILE);
String filename = numNoRange.toString();
copyFile(scrFile, new File("location were you want the file to be saved" + filename + ".png")); //Change location were you want the file to be saved
} catch (NullPointerException n) {

By Pavandeep Puddupakkam on January 8, 2014 | Java, WebDriver | A comment?
Tags: , ,

Wait for at-least one element condition Selenium Webdriver 

There are a lots of situations in your automation scripts where you are waiting for an element to be verified on the page and you may get an error and the script still waits for the element to be loaded on the page rather than catching the error.
Here is the script that will do that and you can also stipulate the timeout for the condition.
The Script is coded in Java Selenium Webdriver and used the Java 5 for loop.

public void waitForOneElementPresent(int i, By... by) throws InterruptedException {
boolean found = false;
for (int second = 0; second <= i; second++) {
if (second >= i) {
for (By singleBy : by) {
if (isElementPresent(singleBy)) {
found = true;
if (found) {

By Pavandeep Puddupakkam on July 24, 2013 | Java, WebDriver | A comment?
Tags: , , ,

Read a XML test data in Java 

Here is the code to read the xml test data coded in Java.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;

public class ReadXmlData {
public String value;

public String data(String node) {
try {
File file = new File("../TestData.xml"); // XML file path
FileInputStream fileInput = new FileInputStream(file);
Properties properties = new Properties();
Enumeration enuKeys = properties.keys();
while (enuKeys.hasMoreElements()) {
if (((String) enuKeys.nextElement()).contains(node)) {
value = properties.getProperty(node);
} catch (FileNotFoundException e) {
} catch (IOException e) {
return value;

By Pavandeep Puddupakkam on July 22, 2013 | Java | A comment?
Tags: , , , ,

Automation Tips
Automation Tools
QA Interview Q&A
Selenium IDE
Selenium RC
Software Testing