Selenium WebDriver Quick Tutorial

Selenium WebDriver Quick Tutorial

i) Introduction to Selenium WebDriver

ii) Selenium WebDriver Environment Setup

iii) Web Elements and Operations

iv) Element Locators

v) WebDriver API Commands
i) Introduction to Selenium WebDriver

> Selenium WebDriver is a programming Interface, no IDE

> Selenium WebDriver supports various Programming Languages to write programs (Test Scripts)

> Selenium WebDriver supports various Operating Environments.

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

> Using Element Locators and WebDriver Commands we can create Test Cases.

> Its support Batch Testing, Cross Browser Testing and Data Driven Testing
Drawbacks of Selenium WebDriver

> It doesn’t have IDE, so difficult to create Test cases and takes more time.

> It doesn’t have built-in Result Reporting facility.

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


i) Download and install Java (JDK) software. – To create and execute programs (Test scripts)

ii) Download Eclipse IDE and extract. – To write and execute Java programs.
iii) Download Selenium WebDriver Java Language binding (from and add WebDriver jar files to Java project in Eclipse IDE.
v) Firefox Driver is default driver in Selenium Webdriver, for IE, Chrome and Safari etc… Browsers we need to download browser drivers and set path.
Manual Test Case:

Test Case ID: gcrshop_admin_TC001

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

Test Steps:
i) Launch the Browser and navigate to “”
ii) Enter User name
iii) Enter Password
iv) Click “Login” Button

Input Data / Test Data:
User name =admin
Password = admin@123

Verification Point:
Capture the Url (Actual) after Login to Application and Compare with Expected.

Expected URL: “”

Test Result:
1) Element Locators – To Identify the Elements

Example for Elements: Link, edit box, Button etc…
Examples for Operations on Elements: Click, Enter a Value, Check, select etc…

2) WebDriver Commands – Perform Operations on Elements

3) Java Programming – To enhance Test cases
Object / Element Property/Locator Value
Man name Santosh
height 6
Object name abc
Dog color white
weight 5
Edit box name Email
Button id tdb1
Selenium WebDriver Test Case:

public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();//Launches Firefox Browser with blank url.
driver.get(“”);//Naviage 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 the Browser
iii) Web Elements and Operations on Elements

a) WebElements

Edit box
Image, Image Link, Image Button
Text Area
Check box
Radio Button
Drop down box
List box
Combo box
Web Table/ HTML Table
b) Operations on Elements

i) Browser
(Launch Browser, Navigate to specified URL, Navigate back, Navigate forward, refresh, close Browser….)

ii) Page
(Return Page Title, Return Page URL…)

iii) Link
(Click, Check the existence, Check Enabled status ….)

iv) Button
(Click, Check Displayed status, Enabled status, return button name ….)

v) Image
a) General Image (Return Image Title etc…
b) Image Button (Click, Check Displayed status, Enabled status, return button name ….)
c) Image Link (Click, Check the existence, Check Enabled status ….)

vi) Text Area / Error Message

(Return Text Area/ Return Error Message etc…)

vii) Radio Button
(Check Displayed status, Enabled status, Select….)

viii) Check box
(Check Displayed status, Enabled status, Select, Unselect, check Selected status….)

ix) Drop down box
(Check Displayed status, Enabled status, Select an Item, Get Items Count ….)

x) List Box
(Check Displayed status, Enabled status, Select one or more Items, Get Items Count ….)

xi) Combo box
(Check Displayed status, Enabled status, Select an Item, Enter an Item, Get Items Count ….)

xii) Web Table
(Return specified Cell value, Return Rows Count, Column Count etc…)

xiii) Frame
(Switch from Top window to specified frame, Frame to Top window

inLine Elements
iv) Element Locators

What is Locator?

> It is an address that identifies a Web element uniquely within the page.

Selenium supports 8 Element locators to recognize elements in web pages.









By.elementLocator(“element locator value”)


driver -Browser Object

findElement- WebDriver Method / Command

By – Built in Class

id – Locator

Email – Value

sendKeys -WebDriver Method / Command

India – Input Data







v) WebDriver Commands / Methods

> Selenium WebDriver methods/commands are used to perform operations on Web Elements.

> Using Element Locators and WebDriver Methods we create Test Cases.

Element Locators – To recognize / Identify Elements

WebDriver Methods – To perform operations on Elements
Important WebDriver API Commands

1) get() – Opens a specified URL in the Browser window.

2) getTitle() – Returns the Browser Title.

String Title = driver.getTitle();
3) getCurrentUrl() – Returns Current URL of the Browser

String Url = driver.getCurrentUrl();
4) navigate().to() – Loads a new page in the current browser window.

5) navigate().back() – It moves a single item back in the Browser history.

6) navigate().forward() – It moves single item forward in the browser history.

7) navigate().refresh() – Refreshes the Current web page

8) close() – Closes the focused Browser.

9) findElement() – Finds the first Element within the current page using given locator.

10) sendKeys() – Enters a value into Edit box/Text box.

11) clear() – It clears the value from Edit box

12) click() – Clicks an Element (Buttons, Links etc…)

13) isEnabled() – Checks weather the Element is in Enabled state or not?

boolean a = driver.findElement(“next”)).isEnabled();
14) isDisplayed() – Checks weather the Element is displayed or not?

boolean a = driver.findElement(By.linkText(“Gmail”)).isDisplayed();
15) isSelected() – Checks weather the Element is selected or not?

boolean after = driver.findElement(By.xpath(“html/body/input[3]”)).isSelected();
Selenium Quick Tutorials

Tutorial 1: Introduction to Selenium

Tutorial 2: Selenium Test Life Cycle

Tutorial 3: Java Quick Tutorial for Selenium Part-1

Tutorial 4: Java Quick Tutorial for Selenium Part-2

Tutorial 5: Selenium Quick Tutorial Part-1

Tutorial 6: Selenium Quick Tutorial Part-2

Tutorial 7: TestNG Framework in Selenium

Follow me on social media: