Selenium WebDriver Tutorial for Beginners

Selenium WebDriver Tutorial for Beginners

i) Introduction to Selenium WebDriver

ii) Selenium WebDriver Environment Setup

iii) Write first Selenium Test Case
i) Introduction to Selenium WebDriver

Selenium's Tool Suite
Selenium IDE
Selenium RC
Selenium WebDriver
Selenium Grid
Selenium WebDriver:

> In 2006, Selenium WebDriver was launched at Google.

> In 2008, the whole Selenium team decided to merge Selenium RC with Selenium WebDriver in order to form more powerful tool called Selenium 2.0

Selenium 1.0 + WebDriver = Selenium 2.0

Selenium 1.0
(Selenium IDE + Selenium RC + Selenium Grid)

Selenium 2.0
(Selenium IDE + Selenium RC + Selenium WebDriver + Selenium Grid)

Note: Now Selenium RC is only for maintenance Projects.
Selenium WebDriver Features:

> It has Programming Interface only, no IDE
 Selenium IDE : 
We can create Test cases using Recording feature and enhance Test cases using Selenese Commands/ Selenium IDE Commands.

Using Element Locators and Selenese Commands we create Test cases in Selenium IDE.

No Programming in Selenium IDE.

Selenium WebDriver:

We create Test Cases using Element Locators and WebDriver Methods/Commands, Enhance Test cases using programming features.

No IDE in Selenium WebDriver.


We create Tests using Tool features (Ex: Recording etc...)and enhance Tests using Tool features (Ex: Checkpoints, Output values, Data Table etc...) and Script/Programming features (Ex: Conditional Statements, Loop Statements, Functions etc...).

IDE as well as Programming Interface.
Test Design

Generate Basic Tests/Test Cases
Enhance Tests

Object Property Value Operations

Dog name abcd Run, Jump etc...
height 40 Cm
color black
weight etc... 10 Kg

Man name
Age etc...

Object Property Value Operations

Link text Gmail Click, check enabled status etc...
enabled true
visible true


Element Locator Value Operations

Edit box id Email Enter a Value, Check enabled status
> Selenium WebDriver supports various programming languages to write Test scripts.


> Selenium WebDriver supports various Browsers to create and execute Test Cases

Mozilla Firefox

Google Chrome



Opera etc...

> Selenium WebDriver supports various operating environments

MS Window
Macintosh etc...

> Selenium WebDriver supports Data Driven Testing and Cross Browser Testing.

> Selenium WebDriver is faster in test execution when it compares to other Functional Test tools.

> Selenium supports parallel test execution.

> Selenium WebDriver supports Batch Testing with the help of either JUnit or TestNG Framework.
Drawbacks of Selenium WebDriver:

> Selenium WebDriver doesn't have IDE (No Tool features), so creating test cases takes more time and efforts.

> Selenium WebDriver supports only Web Applications (doesn't support Desktop Applications)

> No built in Result Reporting facility

> No reliable Technical support

> Limited support for Image Testing

> No other tool integration for Test Management.
ii) Selenium WebDriver Environment Setup


1) Download and Install Java (jdk) software - To create and execute programs (Test Scripts)

2) Set Environment variable (Path Variable) - Optional (only for Command line)

3) Download Eclipse IDE and Extract. - To write and execute Java programs.
4) Download Selenium WebDriver Java Language binding from and Add WebDriver
jar files to Java Project in Eclipse IDE.
ii) Selenium WebDriver Environment Setup:

Download Selenium WebDriver Java Language binding and extract.

Add Selenium WebDriver Java langauge binding to Java Project in Eclipse


> Create Java Project
> Select Java Project and Right click
> Build path
> Configure Bulid path
> Select Libraries Tab
> Click "External Jars"
> Browse path of Selenium WebDriver jars
> Add
iii) Create Selenium WebDriver Test Case:

Manual Test Case:

a) Test Case ID: gcrShop_admin_TC001

b) Test Case Name: Verify Admin Login in GCR Shop web portal.

c) Test Steps:
1) Launch the Browser and Navigate to ""
2) Enter Username
3) Enter Password
4) Click "Login" Button
d) Verification Point/s

Capture URL after Login and compare with expected.



e) Input Data / Test Data

Username = "admin"
Password = "admin@123"

f) Result: Pass
Inspect Elements

Mozilla Firefox - Page Inspector (Built in Feature) to inspect Elements/ Download and Install Firebug Plug in

Google Chrome - Developer Tools (Built in) / F12

IE - Developer Tools (Built-in) / F12
Selenium WebDriver Test Case:

public static void main(String[] args) {
WebDriver driver= new FirefoxDriver();//Launches Firefox browser with blank url
driver.get(""); //Navigates to Admin Home page

String URL = driver.getCurrentUrl();

if (URL.equals("")){
System.out.println("Login Successful - Passed");
else {
System.out.println("Login Unsuccessful - Failed");
driver.close();//Closes Browser


Post a Comment