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 it’s 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 command from the selenium scripts and pass them to the respective browsers in order to automate the web application.
In this way, these browser drivers allow communication between the Selenium script with the different browsers 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 Java language. Using the JSON wire protocol, the Selenium client communicates with the browser driver (Firefox in case of our example) to 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 to setup Selenium on your machine and 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 find him on LinkedIn.