Introduction

Selenium was developed in 2004 by Jason Huggins, a Thoughtworks engineer, to address the shortcomings of manual testing. He developed a solution in the form of a program using JavaScript. He initially named it JavaScript TestRunner. Later on, when he realized that the program could do much more, he renamed it Selenium Core and open-sourced it.

Next Selenium Remote Control (RC) or better known as Selenium 1 was developed by Paul Hammant, another ThoughtWorks engineer. Selenium RC was developed to solve domain-related issues while testing web applications.

This further escalated to the development of Selenium Grid for parallel testing purposes. Next, Selenium IDE was developed to automate the browser through the record and playback features (similar to UFT/QTP). In 2008, the Selenium team decided to merge the web driver and Selenium RC into a tool called Selenium 2, which later evolved to Selenium 3 or better known as Selenium WebDriver. Selenium RC is now deprecated and moved to legacy packaging.

 What is Selenium?

Selenium is an open-source framework used to automate the testing of web applications. If you are looking forward to automating functional and regression test cases, then  would be the right choice! Test scripts can be written in using different programming languages like Java, Python, C#, Ruby, and JavaScript.

What is Selenium WebDriver?

Selenium WebDriver is currently the most widely used component in the Selenium tool suite. Selenium WebDriver: Selenium 2 integrated with WebDriver API provides an understandable programming interface. JAVA and C# languages are mostly preferred to work with Selenium.

 Architecture

Selenium WebDriver is currently the most widely used component in the Selenium tool suite. Selenium WebDriver: Selenium 2 integrated with WebDriver API provides an understandable programming interface. JAVA and C# languages are mostly preferred to work with Selenium.

Before diving into Selenium WebDriver architecture, let us look at its components.

Selenium 3’s architecture consists of five layers.

1.Selenium Client Library

Selenium Client Library or language bindings is a programming library that consists of commands in the form of an external jar file that are compatible with Selenium protocol/W3C Selenium protocol. The selenium client library can be divided into two groups:

Web Driver protocol clients

They are thin wrappers around WebDriver protocol HTTP calls. Based on the user’s preferred programming language, the library can be downloaded from Selenium’s official repository. The library can later be added while creating a new project or a new Maven project in Eclipse or IntelliJ.

WebDriver-based tools

These are higher-level libraries that allow us to work with WebDriver automation. Testing frameworks like Selenide, webdriver.io, or AI-powered Selenium extensions like Healenium come under this group. These tools rely on lower-level webdriver protocols to function efficiently.

2.Selenium API

Selenium API is a set of rules and regulations that the programs use to communicate with each other. APIs work as an interface between the program and aid in their interaction without any user knowledge.

3.JSON Wire protocol

JSON is used in web services in REST and is a widely accepted method for communication between heterogeneous systems. The Selenium WebDriver uses JSON to communicate between client libraries and drivers. The JSON requests sent by the client are converted into HTTP requests for the server’s understanding and again converted back to JSON format while sending it to the client again. This data transfer process is serialization. By this method, the internal logic of the browser is not revealed, and the server can communicate with the client libraries, even if it is not aware of any programming language.

4.Browser Drivers

Browser drivers act as a bridge between the Selenium libraries and the browsers. They help to run Selenium commands on the browser. Each of the browsers has separate drivers, which can be downloaded from Selenium’s official repository. While using a browser driver, we need to import the respective Selenium package “org.openqa.selenium.[$browsername$];” in our code. We should also set the System property of the executable file of the browser driver using the following syntax:

System.setProperty(key, value)

Where the key is the driver’s name and value is the path to the executable file of the driver in the user’s device.

5.Browser

All the browsers supported by Selenium come under this category. Selenium test scripts can be run across various browsers like Chrome, Safari, Firefox, Opera, and Internet Explorer and operating systems like Windows, Mac OS, Linux, and Solaris.

Quick notes

  • Selenium architecture comprises 5 components; Selenium Client Library, Selenium API, JSON Wire Protocol, Browser Drivers, and Browsers.
  • Selenium Client library – Selenium commands in the desired programming language in compliance with the W3C Selenium protocol.
  • Selenium API – Facilitates software-to-software interaction.
  • JSON Wire Protocol – Communication method between client libraries and drivers.
  • Browser drivers – Support interaction between Selenium library and web browser.

Working 

Imagine the working of Selenium WebDriver like a conversation between you, a foreign tourist, and your friend. The tourist is asking for directions, but you are new in the city. You know the tourist’s language, but your friend knows the directions in and out. So, you ask the tourist what they want in their language, and translate it for your friend. Your friend tells you the directions in a jiffy, and you quickly explain it to the tourist in their language. Sounds simple right? Now let us relate this scenario with the components in our Selenium Architecture!

Here’s an example script for login written in Selenium JAVA (Element values used are for illustration purposes)

Package InterviewBitBlog;

import.org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.testng.Assert;

Public class IBContent{

@BeforeTest

Public void login(){

System.setProperty("webdriver.chrome.driver", "C:\\downloads\\chromedriver.exe")

ChromeDriver driver=new ChromeDriver

@Test

public void loginAutomationTest() {

driver.get("www.samplelogin.com");

Assert.assertEquals(driver.getTitle(),"Home");

WebElement signInLink = driver.findElement(By.linkText("signin"));

signInLink.click();

WebElement user = driver.findElement(By.id("username"));

user.sendKeys("test");

WebElement pass = driver.findElement(By.id("password"));

pass.sendKeys("test");

WebElement log = driver.findElement(By.name("Login"));

log.click();

}

Advantages

  • It is open-source, supports many languages, and is compatible with many operating systems.
  • Selenium WebDriver architecture is designed to support cross-browser testing and parallel testing.
  • Selenium WebDriver supports integration with various frameworks like Maven, and ANT for code compilation.
  • It also supports integration with testing frameworks like TestNG to improve automation testing and reporting.
  • Selenium can be integrated with Jenkins for CI/CD purposes.
  • Selenium has strong community support which makes troubleshooting pretty easy.

 Disadvantages

  • It does not support testing of Windows applications as it works only on web applications.
  • It depends on third-party frameworks like TestNG and Cucumber for reporting, as it does not have inbuilt reporting features.
  • This  architecture is not prepared to handle dynamic web elements accurately, thus affecting test results.
  • It  does not handle frames and pop-ups efficiently.
  • It  does not automate captcha, barcodes, and test cases that involve fingerprints.

Conclusion

I hope this article gave you a fair idea of Selenium Architecture. If you are preparing for interviews based on Selenium, then check out our Selenium Interview questions compilation. Visit InterviewBit for more resources and training programs to help you crack those tough interviews in your dream companies!

FAQs

1.What is Selenium architecture?

Selenium architecture refers to the structure and components of the Selenium automation testing framework. It includes various layers and components that work together to automate web testing.

2.What are the key components of Selenium architecture?

The key components of Selenium architecture include Selenium Client Library, Selenium API, JSON Wire Protocol, Browser Drivers, and Browsers.

3.What is the role of Selenium Client Library?

Selenium Client Library provides commands in the form of external jar files that are compatible with the Selenium protocol. It allows users to write test scripts in their preferred programming languages.

4.What is the significance of JSON Wire Protocol in Selenium?

JSON Wire Protocol is used for communication between client libraries and drivers. It converts client requests into HTTP requests for the server’s understanding and ensures seamless interaction between components.

5.What are Browser Drivers in Selenium architecture?

Browser Drivers act as bridges between Selenium libraries and web browsers. They facilitate the execution of Selenium commands on browsers. Each browser has its own specific driver.

Categorized in: