Selenium Web Driver: An Introduction

07 / Dec / 2014 by Gaurav Gupta 4 comments

Selenium WebDriver is a clean, fast framework for automated testing of webapps.

Selenium WebDriver, a popular and well established testing framework is a wonderful tool that provides a handy unified interface that works with a large number of browsers and allows you to write your tests in almost every language you can imagine from Java or C# through Ruby, Python to JavaScript. It is one of the first Open Source projects to bring browser-based testing to the masses.

It aims to provide a friendly API that is easy to explore and understand, which will help make your tests easier to read and maintain down the line.

It is not tied to any particular test framework, so it can be used equally well with JUnit, TestNG or from a plain old “main” method.

Guide to “Getting Started”

This “Getting Started” guide introduces you to WebDriver’s Java API and helps get you started becoming familiar with it.

  • Start by downloading the latest binaries and unpack them into a directory.
  • Start a new Java project in your favourite IDE
  • Add all the JAR files from the directory to the CLASSPATH of the Java project

You can see that WebDriver acts just as a normal Java library does, it’s entirely self-contained, and you don’t need to remember to start any additional processes or run any installers before using it.

You’re now ready to write some code. An easy way to get started is this example, which open the Firefox browser and searches for the term “Selenium Web Driver” on Google and then outputs the result page’s title to the console.

package com.intelligrape.selenium.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Example {
public static void main(String[] args) {

// create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();

// go to “” to visit Google

// find the text input element by its name
WebElement element = driver.findElement(“q”));

// enter something to search for
element.sendKeys(“Selenium Web Driver”);

// now submit the form.

// check the title of the page
System.out.println(“Page title is: ” + driver.getTitle());

//close the browser

Gaurav Gupta



comments (4)

  1. Ram

    Sweet way of presenting the concepts for a Selenium beginner. It would be wise to mention in CAPS and BOLDS that JAVA is the pre-requisite for Selenium.


Leave a Reply

Your email address will not be published. Required fields are marked *