Selenium Webdriver Tutorial

Selenium WebDriver Tutorial

Selenium Webdriver tutorial provides basic concepts of Selenium. Our tutorial is designed for beginners as well as for professionals. This online course is a step by step guide to learn Selenium Concepts. It is highly suggestible to refer the tutorials sequentially, one after the other. If you are new to testing first take the basic Software Testing.

Selenium is an open-source Web UI (User Interface) automation testing suite. It is widely used to automate the testing of web applications. 

Section 1Selenium WebDriver Introduction
Lecture 1What is Selenium? Introduction to Automation TestingFree Preview

What is Selenium ? Introduction to Automation Testing

Selenium is one of the most widely used Web UI (User Interface) automation testing suite. It is an open source tool which is used for automating the tests carried out on different web browsers and platform.

Advantages of Selenium over other tool:

Programming Language supported: Java, Python, C#, PHP, Ruby, Perl & .Net

Supports OS (Operating System) for Web Application: WindowsMac or Linux

Supports OS (Operating System) for mobile applications: iOS, windows mobile and android

Browsers supported: Internet Explorer, Mozilla Firefox, Google Chrome and Safari

Integrate with Framework for managing testcases and generating reports: TestNG & JUnit

Integrate with automation test tool to Achieve continuous testing: Maven, Jenkins & Docker

Advantages of Selenium over other tool

Section 2Setting Up Your Environment
Lecture 5Run Test on Chrome BrowserFree Preview

Run First Test on Chrome Browser

Chrome browser implements the WebDriver protocol using an executable called ChromeDriver.exe. This executable starts a server on your system which will be responsible for running your test script in selenium.

Testcase: Open chrome browser and navigate to and close the browser


Step1: Right click on src folder and select New > Class


Step2: Provide Class Name and click on Finish


Step3: Open URL: in your browser and select any of the latest chrome driver version according to your browser version

Download executable file as per the operating system you are working on.

For windows, click on the “” download and unzip the file.


Set a system property “” to the path of your ChromeDriverServer.exe file and instantiate an ChromeDriver class.

Here below your test script will look like


import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;

public class FirstChromeTest {

public static void main(String[] args) {

// System Property for Chrome Driver
System.setProperty("", "E:\chromedriver.exe");

// Instantiate a ChromeDriver class.
WebDriver driver=new ChromeDriver();

//Maximize the browser window driver.manage().window().maximize();

// Launch Website and navigate to URL

//close the browser



Step6: Run the code by right click on the Eclipse code and select Run As > Java Application

Section 3WebDriver Commands
Lecture 10Browser Navigation CommandFree Preview

Browser Navigation Command

Navigation Commands are able open a web page URL, navigate to another web page or navigate back, Forward or Refresh the web page using browser’s history.

Given below are the Navigation commands for Selenium WebDriver.

1. Navigate.To()

This method is used to redirect to the new web page from the existing web page. It maintains browser history and cookies, unlike get method. It accepts string as a parameter and returns void.


2. Navigate.Forward()

This method takes to the forward page of the existing browser window. It neither accepts anything nor returns anything.


3. Navigate.Backward()

This method takes to the backward page of the existing browser window. It neither accepts anything nor returns anything.


4. Navigate.Refresh()

This method is used to refresh or reload the current page in the existing browser window. It neither accepts anything nor returns anything.



Section 4Locators
Lecture 13ID
Lecture 14Name Free Preview


Name locator is also an effective way to locate an element in Selenium. It is similar way locating elements as that of ID locator. These are not unique on DOM. If there are multiple elements present with the same Name locator in the DOM then the first element on the page is selected while locating with below methods.And if there is no DOM element available with the given Name, then NoSuchElementException is raised in that case.


Syntax: WebElement element = driver.findElement(<NAME>));


Let’s take an example by locating “side menu” in “” page.

Step1: Open in browser

Step2: Hover your mouse to Forms present in side-menu

Step3: Right click on the mouse and do inspect element

Name Locator Example

element = driver.findElement("side-menu-form"));



Lecture 15ClassName
Lecture 16XPath
Lecture 17LinkText
Lecture 19TagName
Lecture 20CssSelector