Selenium Tutorial: Everything you should know

Selenium is an open source freely available automation tool on which Automation Testing is performed. Selenium was developed by an engineer named Jason Huggins in 2004. It is a powerful and robust tool with the help of which web applications are automated so as to ensure that the software is of good quality, fulfilling customer requirements, and are ready to be delivered to the customers. Selenium facilitates the Automation of a large number of functionalities of software applications in different web browsers and operating systems as a result of which the efforts and time of software developers and software testers are saved. Selenium proves to be superior to Manual Testing by delivering better quality software applications to customers in a shorter period of time compared to manual testing.Selenium can be configured in various programming languages like Java, PHP, Python etc. where we can write programming scripts in order to perform automated testing. Using Selenium we can launch different browsers and automate web pages and links.

Platforms on which Selenium works

Selenium works on various platforms which are:

  1. Browsers
  2. Operating Systems
  3. Programming Languages
Browsers which Selenium supports

There are various browsers where we use Selenium for doing cross-browser testing and parallel testing by configuring Selenium with TestNG.We use Selenium Browsers for launching any browser, websites, webpages, getting the title of the web page and  getting the uniform resource locator of the currently running webpage.  We use the Selenium Web Drivers interface for each of these browsers while performing parallel and cross-browser testing. Those browsers are:

  1. Google Chrome
  2. Mozilla Firefox
  3. Internet Explorer
  4. Opera Mini
  5. Safari Browser
  6. Microsoft Edge
Operating Systems

Selenium is compatible with various operating systems for performing test automation of software applications. Those operating systems are:

  1. Microsoft Windows
  2. MacOS
  3. Linux
Programming Languages

Selenium supports various programming languages which make it easier and convenient for developers and testers to write Automation Scripts in these languages. They also prepare Automation suites using the programming languages which also meet the needs of the project. The various programming languages are:

  1. Java
  2. Python
  3. C#
  4. Ruby on Rails
  5. Java Script
  6. PHP
Components Of Selenium

Selenium consists of various components that help testers perform automated testing like parallel testing, cross-browsertesting on different browsers as well as record and play those actions. The various components of Selenium are:

  1. Selenium IDE
  2. Selenium Web Driver
  3. Selenium Grid
  4. Selenium Remote RC (Discontinued in Selenium version 4)

The schematic diagram of all selenium components before Selenium version 4 is shown below

Selenium IDE

Selenium Integrated Development Environment(Selenium IDE) is one of the most commonly used tools present in Chrome Browser, Firefox Browser, and Edge Browser. It is an easy-to-use tool that records actions as well as plays those actions with the help of various Selenium commands as well as parameters associated with those commands. This ensures learning of Selenium codes in a systematic way. The commonly used Selenium commands are assert, verify, and type and the locators used are id, name, Xpath, and CSS selector. In Selenium IDE we export test cases in different formats.

Selenium Web Driver

Selenium Web Driver is also known as simply Web Driver. Using Web Driver we can launch an empty browser. With the help of Web Driver, we can run the test Automation suites in different browsers, operating systems, and programming languages. It is mostly helpful for testers during parallel testing, cross-browser testing, and cross-platform testing. It creates customised test results and also tests software applications that have AJAX-based functionalities. Web Driver is basically interface in nature. For launching browsers using web driver we basically upcast  the web driver to that particular browser driver. For example if we want to launch ChromeBrowser we upcast the web driver to the driver of chrome browser called chromedriver. Likewise for launching firefox browser and edge browser we upcast  webdriver to firefox driver and edge driver respectively. The launching of different empty browsers take place after importing the web driver alongwith each of the browser drivers. But before that we need to configure the selenium in each of the programming languages in order to get the import of webdriver and browser drivers. 

					Syntax of launching Chrome Browser using WebDriver is: WebDriver driver= new ChromeDriver();
Syntax of launching FireFox Browser using WebDriver is: WebDriver driver= new FirefoxDriver();

Syntax of launching Edge Browser using WebDriver is: WebDriver driver= new EdgeDriver();


In each of the following syntaxes the driver is called the reference variable of web driver.

Selenium Grid

Selenium Grid is used by service based companies to run the same test scenarios and test cases on multiple devices, multiple browsers and operating systems. It is used to run a very large test suite that is to be completed in a short period of time. Testers use Selenium Grid to run Test automation scripts while performing parallel testing, cross-browser testing, and cross-platform testing after connecting their servers on remote machines.

Selenium Remote RC

Selenium Remote Rc was the first tool that was used by testers for performing parallel testing, cross-browser testing, and cross-platform testing. It was used to run test cases in different browsers(except HtmlUnit), programming languages, and operating systems. It was used to design test cases in a convenient language. It was used to Automate applications having AJAX-based functionalities. It was mostly used to automate only those web applications that support JavaScript as a result of which Selenium Remote RC is no longer available.

Advantages of Selenium
  1. It is a free tool available in the market.
  2. With the help of Selenium, we can automate testing in multiple programming languages.
  3. It can be automated in multiple operating systems. (Windows, MacOS, Ubuntu)
  4. It can be automated in multiple browsers.
  5. Selenium reduces the effort required in Manual testing to a very great extent and also there is less probability of errors compared to manual testing.
  6. Testing process is more smooth and reliable than manual testing.
  7. Selenium configured with TestNG enables reusability of test scripts.
Disadvantages of Selenium
  1. With the help of Selenium, we can Automate only web-based applications, not mobile and standalone applications. So for automation of mobile applications and standalone applications we need to use some additional tools.
  2. Selenium does not have any official documentation. As a result of which testers have to depend on other third party testing tools like TestNG for generation of test reports.
  3. We will not be able to automate image, OTP, Scan code Captcha, and Barcode using Selenium.
  4. Test Scripts made through selenium need to be updated every time due to constant updates of web applications.
  5. Through Selenium we cannot perform image based testing like screenshot comparison, which is needed for testing visual aspect  of software application. 
  6. Wherever there is no scope for code reusability, creation of Test Cases takes more time due to writing of programming code for every test cases
Architecture of selenium web driver

Software testing is a very important part of software development life cycle process. Without testing we will not be able to deliver a good quality software to customers. In the present competitive environment there is a need to deliver a quality product within a very short interval of time. To fulfil this requirement Automation testing is done. Of late web based applications are having heavy demand in the market and are used for performing all kinds of real life activities. So testing of web applications has become very crucial. Selenium , an open source tool fulfils the purpose of testing web based applications.  Selenium also has key components for testing of web based applications. Selenium web driver is one such component of selenium framework for performing automation testing of web applications . It consists of group of APIs which provides a proper user interface and environment for developers and testers for writing test scripts in different programming languages like Java,Python,PHP and Ruby on Rails. WebDriver performs various actions in the test scripts like launching browsers, navigation from one web page to another web page, actions on components like radio buttons, checkboxes, text field, text areafield,and performing actions on hoverover, links.  

The architecture of Selenium Web Driver are:


Selenium provides a platform for sending the requests which is referred to as Client. The client simply refers to programming languages where we send requests in the form of programming code snippets. The various programming languages which act as client are Java, PHP, Python Ruby on Rails etc.

JSON Wire Protocol:

 JSON refers to Java Script Object Notation. With the help of JSON there is smooth transfer of data between client and server. The client sends the requests to the server and the server sends back the response to the client through JSON. This component is basically present in Selenium 3 web driver.

W3 Protocol:

 With the help of W3 Protocol  there is more  smooth transfer of data between client and server as compared to JSON wire protocol. The client sends the requests to the server and the server sends back the response to the client through JSON. This component is basically present in Selenium 4 web driver.

Selenium Browser Drivers:

 For each of the web browsers there are selenium drivers. Selenium drivers are used to run the program code smoothly and effectively. Browser drivers provide a proper connection with the browsers. The various lists of browser drivers are chromedriver for chromebrowser, GeckoDriver for firefox browser, Microsoft edge web driver for microsoft edge browsers, internet explorer driver for internet explorer browsers  and Safari Driver for Safari browsers


 Automation testers perform the testing for various web based applications in Selenium through different browsers. The most common browsers are ChromeBrowsers, FireFoxBrowsers,EdgeBrowsers, Safari Browsers etc.

Given below is the schematic diagram of  Selenium3 WebDriver

The schematic diagram below is of Selenium 4 WebDriver


WebElement also known as html element which is used to perform operations on various web pages, browsers and links. The various web pages operations are getting the title of web page, url of web page. The various operations performed on browsers are launch,navigate,maximise and minimise and the operations performed on the link are clicking on the link and return to the home page. Web Element is interface in nature which has many abstract methods in it like find element, find elements, Is enabled, Is disabled, Is selected, get location, click, size, sendkeys etc

					Syntax of web Element
WebElement element1= driver.findElement(“Username”);

Types of Selenium Command
1.Browser Command

Selenium is a very powerful free open source tool for automating web based applications using different browsers.Developers and Testers perform automation testing of web based applications on different browsers with the use of various commands called as browser commands.Browser Commands consists of various inbuild methods that enables developers and testers to perform actions on different browsers like getting the title, source code  and current url of the web pages.

The browser commands consist of get() command,getTitle() get currentUrl() command, Close Command and Quit Command. The browser commands are written as Driver.get(url),Driver.getTitle(),Driver.getcurrentUrl(),Driver.close() and Driver.quit(). Driver.get() is used to launch any particular web page or website. Driver.getTitle() is used to get the title of any webpage or website. Driver.getCurrentUrl() is used to get the resource locator of the webpage or website which is currently running or in other words it prints the url of the ongoing  webpage or website. Driver.close is used to close that particular browser on which there is control and driver.quit is used to close the entire browser. 

					Syntax of close command: driver.close();
Syntax of quit command: driver.quit();
Syntax of get command: driver.get();
Syntax of getTitle() command: driver.getcurrentUrl();
Syntax of getCurrentUrl() command: driver.getTitle();
The schematic representation for the  browser commands are 

2.WebElement Command

The web element commands are sendkeys,is enabled,is displayed, find element,find elements. Find Element is used for finding a single element like to find a link. The return type of find element is web element. FindElements is used to find multiple elements like in case of autosuggestions. The return type of find elements is list<Web Element>. Is Displayed is an abstract method of webelement interface which is used to check if the given element is displayed or not. The return type of is displayed is boolean which returns true if the given element is displayed and returns false if the given element is not displayed and accordingly based on true or false actions are performed on the element. Is Enabled is used to check if the element is enabled or not . Is enabled is an abstract method of web element interface whose return type is boolean . If Is enabled is true then we can say the given element is enabled and actions are performed on that element but if is enabled is false then the given element is not enabled as a result we get disabled component exception on performing action on that disabled element. Sendkeys is used to type a particular thing automatically while performing  component automation testing on text field, text area field. Sendkeys is also used alongwith virtual enter keys  to click on any link without using click method. 

Syntax of FindElement:
					Syntax of FindElement: 
WebElement flipcart= c1.findElement(By.xpath("//span[.='✕']"));;

Syntax of FindElement:
					Syntax of FindElements: 
List<WebElement> autosuggestion = c1.findElements(By.xpath("//form[@class='_2rslOn header-form-search OpXDaO']/ul/li"));
	 int noofautosuggestion = autosuggestion.size();

Syntax of IsEnabled:
					Syntax of IsEnabled: 
boolean yln= a.isEnabled();	
			 WebElement a1= c1.findElement("1"));

Syntax of IsDisplayed:
					Syntax of IsDisplayed:
	boolean ans= a.isDisplayed();

Syntax of SendKeys:
					Syntax of SendKeys:
  WebElement link = c1.findElement(By.tagName("a"));


The schematic representation of WebElement commands are:

3.Navigation Command

Navigation commands are Navigate to,Navigate refresh,Navigate back,Navigate forward. Navigate to is used for launching any web page or website. Navigate refresh is used to refresh something after performing any activities on the website. Navigate back is used to go back to the previous web page. Navigate forward is used to proceed to the next page.

					Syntax of Navigation Commands:

Navigate to: c1.navigate().to("");
Navigate Back: c1.navigate().back();


The schematic diagram of navigation commands are


Selenium is thus a very powerful open source and free automation tool mostly used by testers and developers for performing automated testing on a variety of web based applications. It thus saves a lot of time and effort as compared to the manual testing of web based software applications as a result of which huge amounts of good quality web based  software applications are released into the market in a very short interval of time resulting in great customer satisfaction.

Also, automation testing with Selenium training has equipped you with the tools and knowledge to effectively implement automation testing in your projects. By utilizing Selenium’s powerful features, you can improve testing efficiency, minimize manual errors, and enhance overall product quality. With this training, you are well on your way to mastering automation testing with Selenium and becoming an invaluable asset to your team and organization. Keep practicing, exploring new features, and staying updated with the latest developments in the field to stay ahead in the ever-evolving world of automation testing.

Upskill Yourself
Consult Us