Selenium Introduction



Introduction :-

Automation has become the buzzword of today, especially in the software industry. Automation helps a lot in enhancing the quality of the product and at the same time it helps to reduces the cost of production also. In other words, cost optimization is also a reason behind the call for automation in many new areas.

Software testing has been automated long back since the invention of many test automation tools. Since then the technology has evolved a lot to contain all types of software testings and different test automation tools have been introduced. Of the many tools, Selenium remains the numero uno among the test automation tools.Selenium was originally developed by Jason Huggins in 2004 as an internal tool at ThoughtWorks.

At present, there is a huge demand for selenium experts and this is the right time to make use of it. Reports are coming from different corners of the world about laying offs in many industry. Many experts are accusing automation as the major reason behind cutting down the manpower. It is true to some extent but automation cannot be blamed for losing jobs as it provides many new opportunities.

Selenium has four components :-

  1. RC(Remote Control)

  2. IDE(Integrated development environment)

  3. WebDriver

  4. Grid

Brief Introduction Selenium IDE

Selenium Integrated Development Environment (IDE) is the simplest framework in the Selenium suite and is the easiest one to learn. It is a Firefox plugin that you can install as easily as you can with other plugins. However, because of its simplicity, Selenium IDE should only be used as a prototyping tool. If you want to create more advanced test cases, you will need to use either Selenium RC or WebDriver.






its very easy to use and install

restrict only with firefox driver


can export text to formats usable in RC and Webdriver

No support for iteration and conditional operations


Has built-in help and test results reporting module

Test execution is slow compared that of selenium RC and WebDriver.

Brief Introduction Selenium Remote Control (Selenium RC)

Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool that allowed users to use a programming language they prefer. As of version 2.25.0, RC can support the following programming languages:

  • Java

  • C#

  • PHP

  • Python

  • Perl

  • Ruby


Brief Introduction WebDriver

The WebDriver proves itself to be better than both Selenium IDE and Selenium RC in many aspects. It implements a more modern and stable approach in automating the browser's actions. WebDriver, unlike Selenium RC, does not rely on JavaScript for Automation. It controls the browser by directly communicating with it.

The supported languages are the same as those in Selenium RC.


  • Java

  • C#

  • PHP

  • Python

  • Perl

  • Ruby

Selenium Grid

Selenium Grid is a tool used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time. Parallel execution means running multiple tests at once.


  • Enables simultaneous running of tests in multiple browsers and environments.

  • Saves time enormously.

  • Utilizes the hub-and-nodes concept. The hub acts as a central source of Selenium commands to each node connected to it.

A Comparison between Selenium and QTP(now UFT)

Quick Test Professional(QTP) is a proprietary automated testing tool previously owned by the company Mercury Interactive before it was acquired by Hewlett-Packard in 2006. The Selenium Tool Suite has many advantages over  QTP as detailed below -

Advantages of Selenium over QTP




Open source, free to use, and free of charge.


Highly extensible

Limited add-ons

Can run tests across different browsers

Can only run tests in Firefox, Internet Explorer and Chrome

Supports various operating systems

Can only be used in Windows

Can execute tests in parallel.

Can only execute in parallel but using Quality Center which is again a paid product.




What and why selenium Web Driver ?

Selenium WebDriver


If you want to

  • create robust, browser-based regression automation suites and tests

  • scale and distribute scripts across many environments


Then you want to use Selenium WebDriver; a collection of language specific bindings to drive a browser -- the way it is meant to be driven.

Selenium WebDriver is the successor of Selenium Remote Control which has been officially deprecated. The Selenium Server (used by both WebDriver and Remote Control) now also includes built-in grid capabilities.



  • The entire Selenium Tool Suite is comprised of four components:

  • Selenium IDE, a Firefox add-on that you can only use in creating relatively simple test cases and test suites.

  • Selenium Remote Control, also known as Selenium 1, which is the first Selenium tool that allowed users to use programming languages in creating complex tests.

  • WebDriver, the newer breakthrough that allows your test scripts to communicate directly to the browser, thereby controlling it from the OS level.

  • Selenium Grid is also a tool that is used with Selenium RC to execute parallel tests across different browsers and operating systems.

  • Selenium RC and WebDriver was merged to form Selenium 2.

  • Selenium is more advantageous than QTP in terms of costs and flexibility. It also allows you to run tests in parallel, unlike in QTP where you are only allowed to run tests sequentially.


Download selenium from the below link


What is WebDriver ?

WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox (unlike Selenium IDE).it is created by simon stewart in 2006 and officially launch in 2011.


Let’s see how the webdriver works :-

WebDriver also enables you to use a programming language in creating your test scripts (not possible in Selenium IDE).

  • You can now use conditional operations like if-then-else or switch-case

  • You can also perform looping like do-while.

Following programming languages are supported by WebDriver

  • Java

  • .Net

  • PHP

  • Python

  • Perl

  • Ruby

You do not have to know all of them. You just need to be knowledgeable in one.



Selenium Client & WebDriver Language Bindings

In order to create scripts that interact with the Selenium Server (Selenium RC, Selenium Remote WebDriver) or create local Selenium WebDriver scripts, you need to make use of language-specific client drivers. These languages include both 1.x and 2.x style clients.

While language bindings for other languages exist, these are the core ones that are supported by the main project hosted on google code.


Note:-  To automate a simple website we need to have only

  1. Any browser’s driver like Firefox,Chrome,Internet explorer

  2. Selenium .jar with latest version     

  ==>Download version 3.6.0


What Are Browser Elements?

Elements are the different components that are present on web pages. The most common elements we notice while browsing are:

  • Text boxes

  • CTA Buttons

  • Images

  • Hyperlinks

  • Radio buttons/ Check boxes

  • Textarea/ Error messages

  • Drop down box/ List box/ Combo box

  • Web Table/ HTML Table

  • Frame

Locating Browser Elements Present On The Web Page

Every element on a web page will have attributes (properties). Elements can have more than one attribute and most of these attributes will be unique for different elements. For example, consider a page having two elements: an image and a text box. Both these elements have a ‘Name’ attribute and an ‘ID’ attribute. These attribute values need to be unique for each element. In other words, two elements cannot have the same attribute value. Elements can have the same value for ‘Class Name’.

In the example considered, the image and text box can neither have the same ‘ID’ value nor the same ‘Name’ value. However, there are some attributes that can be common for a group of elements on the page. I will tell you which are those attributes later, but before that let me list down the 8 attributes using which we can locate elements. Those attributes are ID, Name, Class Name, Tag Name, Link Text, Partial Link Text, CSS and XPath.

Since the elements are located using these attributes, we refer to them as ‘Locators’. The locators are:


  • Syntax: driver.findElement(“abc”));


  • Syntax: driver.findElement(“abc”));

  • By.className

  • Syntax: driver.findElement(By.className(“abc”));

  • By.tagName

  • Syntax: driver.findElement(By.tagName(“abc”));

  • By.linkText

  • Syntax: driver.findElement(By.linkText(“abc”));

  • By.partialLinkText

  • Syntax: driver.findElement(By.partialLinkText(“abc”));

  • By.css

  • Syntax: driver.findElement(By.css(“abc”));

  • By.xpath

  • Syntax: driver.findElement(By.xpath(“abc”));

By looking at the syntax above, you might have realized locators are called inside methods. So, before going any further, you need to learn all the other methods, browser commands and functions that can be used to perform operations on the elements.

This is the most common way of locating elements since ID's are supposed to be unique for each element.

Target Format: id=id of the element

For this example, we will use Facebook as our test app because Mercury Tours do not use ID attributes.

Step 1. Since this tutorial was created, Facebook has changed their Login Page Design. Use this demo page for testing. Inspect the "Email or Phone" text box using Firebug and take note of its ID. In this case, the ID is "email."

Step 2. Launch Selenium IDE and enter "id=email" in the Target box. Click the Find button and notice that the "Email or Phone" text box becomes highlighted with yellow and bordered with green, meaning, Selenium IDE was able to locate that element correctly.

















package seleniumWebDriver;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverClass

public static void main(String[] args)


System.setProperty("webdriver.gecko.driver", "files/geckodriver.exe");

WebDriver driver = new FirefoxDriver();






import org.openqa.selenium.WebDriver; is a library package which contains the required class to initiate the browser loaded with a specific driver.

import org.openqa.selenium.firefox.FirefoxDriver; is a library package which contains the FirefoxDriver class needed to start FirefoxDriver as the browser initiated by the WebDriver class.

System.setProperty(“webdriver.gecko.driver”, “files/geckodriver.exe”); – This command notifies the run-time engine that the Gecko driver is present in the specified path. After Firefox 35, we need to download the Gecko driver for working with WebDriver. In case you want to test on chrome, then you have to download ChromeDriver, which is a .exe file and specify it’s path in this line of code. We have to do it similarly in case of other browsers also.

WebDriver driver = new FirefoxDriver(); – This command is used to initiate a new Firefox driver object.

driver.get(“”); – This method is used to open the specified URL.

driver.getTitle(); – This command gets the title of the tab that is currently open in the browser.

driver.quit(); – This command closes the browser driver.

Locating by CSS Selector

CSS Selectors are string patterns used to identify an element based on a combination of HTML tag, id, class, and attributes. Locating by CSS Selector is more complicated than the previous methods, but it is the most common locating strategy of advanced Selenium users because it can access even those elements that have no ID or name.

CSS Selectors have many formats, but we will only focus on the most common ones.

  • Tag and ID

  • Tag and class

  • Tag and attribute

  • Tag, class, and attribute

  • Inner text


Locating by CSS Selector - Tag and ID

Again, we will use Facebook's Email text box in this example. As you can remember, it has an ID of "email," and we have already accessed it in the "Locating by ID" section. This time, we will use a CSS Selector with ID in accessing that very same element.




  • tag = the HTML tag of the element being accessed

  • # = the hash sign. This should always be present when using a CSS Selector with ID

  • id = the ID of the element being accessed

Keep in mind that the ID is always preceded by a hash sign (#).

Step 1. Navigate to Using Firebug, examine the "Email or Phone" text box.

At this point, take note that the HTML tag is "input" and its ID is "email". So our syntax will be "css=input#email".

Step 2. Enter "css=input#email" into the Target box of Selenium IDE and click the Find button. Selenium IDE should be able to highlight that element.


In the nutshell, if you want to automate a website then selenium will work only 25% only for the remaining 75% we have to integrate the below APIs :-


  • Core java

  • POI .jar

  • Jdbc

  • Java mail

  • Log4j

  • Maven/Ant

  • Jenkins

  • ReportNg   and so on …….


    • Jessianut

      Nice post and basic step by step post was sharing it's useful for beginners of automation test.

    • sandeep

      Thanks for sharing your knowledge. It will be helpful for us.

    • rouseVaf

      Norman Logistics Sp.zo.o. Rolands petersons cpmtreding has released new forecasts on Poland becoming the logistics centre of Europe. Newest OECD (Organisation for Economic Co-operation and Development) data are indicating the increase of living standards in Poland, positive tendencies in economy and rapid development of the labour market. Rolands petersons cpmtreding Experts at OECD has appreciated a change in the Polish labour market - a fall of the unemployment level to the lowest ever, reaching the lowest point in the last twenty years; labour demand is growing; and everything indicates a significant growth of average wages in the near future.Rolands petersons cpmtreding Unemployment levels in Poland in 2017 were low - 4,9% and all the forecast are indicating the continuous fall reaching 4,2% in 2018 and 3,8% in 2019. GDP will go on increasing, but a little bit more slowly. Forecasts for 2018 are 4,2%, but in 2019 - 3,7%. It should be mentioned that in 2017 GDP was 4,6%[1]. Poland should think more about the agricultural production export area. Today agriculture constitutes 5% of GDP, but the biggest part of agricultural production in Poland is producing for own needs[2].Rolands petersons cpmtreding Export products for the most part are milk products, meat and potatoes. By developing its infrastructure, Poland would be able to succeed exports. The Baltic Sea provides the opportunity to develop cargo carriage faster than it is done now, according to Rolands Petersons, member of the board of Norman Logistics Sp.zo.o. who offers his thoughts on Poland economy. To keep this positive tendency, Poland has to find opportunities to invest in proficiency enhancement, development of infrastructure and innovations. Rolands petersons cpmtreding There should be a strategy allowing continuation and even growth of infrastructural investments. Author: Rolands Petersons, member of the board of Norman Logistics Sp.zo.o.

    • nomad