In the previous post on Selenium Introduction of our Selenium Tutorial Series, we learned about the different components of the Selenium, its advantages, and its limitations. This tutorial is based on the main component of Selenium Test Suite i.e. Selenium Webdriver. Here, we will learn about the Selenium WebDriver architecture framework, its different components, and then its functioning.
Selenium WebDriver Architecture
The knowledge of Selenium WebDriver architecture is required for an in-depth understanding of Web-UI automation using Selenium WebDriver. In order to understand the architecture, we first need to know about the four components that comprise this framework.
Selenium WebDriver Architecture Diagram
Selenium Client Library
For each of the supported browsers in Selenium, we have a separate browser driver. These drivers take commands from the selenium scripts and pass them to the respective browsers.
In this way, these browser drivers allow communication between the Selenium script with the different browsers. Also, the communication happens without revealing the internal logic of those browsers.
Some of the browser drivers in Selenium are – FirefoxDriver, ChromeDriver, InternetExplorerDriver, SafariDriver, OperaBrowser, EdgeDriver, and HtmlUnitDriver.
JSON Wire Protocol over HTTP
In the WebDriver architecture, the JSON wire protocol is used for communication between the selenium scripts and the Browser Drivers.
This component of the Webdriver architecture in Selenium is pretty straightforward. The browsers receive the command and call the respective method to perform the desired automation task. The different browsers supported by Selenium are – Chrome, Firefox, IE, Edge, Safari, Opera, etc.
Automation using Selenium WebDriver Explained
Time to see the internal working of the automation of web applications in the different browsers using Selenium WebDriver.
Let’s understand this with the help of the below commands to perform a simple automation task-
WebDriver driver = new FirefoxDriver(); driver.get("https://artoftesting.com"); driver.findElement(By.id("button1")).click();
Now, the script is written in Java. So the Selenium Client Library component helps us in creating the scripts in the Java language. Using the JSON wire protocol, the Selenium client communicates with the browser driver (Firefox in the case of our example). It will perform the get() operation to launch the ArtOfTesting website and then click on a button.
The Firefox browser driver will then send the commands to the respective browser. On successful completion of the automation tasks, the response is sent back to the automation script.
This completes our tutorial on WebDriver architecture in Selenium. After this, you can now continue with the next chapter of our Selenium WebDriver Tutorial series i.e. Selenium WebDriver Setup. The tutorial will help you set up Selenium on your machine. After that, you will be able to test the setup with a sample script.
Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals. You can connect with him on LinkedIn.