DETAILED READ SECTION

Learn Selenium Web Driver Architecture


Selenium Web Driver Architecture every QA Engineer must know if he is looking forward to start career as Automation QA.


In this post will share architecture of Selenium Web Driver and how your test script start performing multiple operations on Web browser.


Behind the scenes its not as easy as it looks. As there is web driver server specific to every browser running who actually responsible for converting test scripts commands into http commands and communication of messages exchanged via json wire protocol.


Selenium Web Driver Architecture contains 4 main components:

  • Selenium Client Library

  • JSON WIRE PROTOCOL Over HTTP

  • ClientBrowser Drivers

  • Browsers

Block Diagram


1. Selenium Client Libraries/Language Bindings


Selenium supports multiple libraries such as Java, Ruby, Python, etc. Selenium Developers have developed language bindings to allow Selenium to support multiple languages. If you wish to know more about libraries, kindly refer to the official site for Selenium libraries.


2. JSON WIRE PROTOCOL Over HTTP Client


JSON stands for JavaScript Object Notation. It is used to transfer data between a server and a client on the web. JSON Wire Protocol is a REST API that transfers the information between HTTP server. Each BrowserDriver (such as FirefoxDriver, ChromeDriver, etc.) has its own HTTP server.


3. Browser Drivers


Each browser contains a separate browser driver. Browser drivers communicate with the respective browser without revealing the internal logic of the browser’s functionality. When a browser driver has received any command then that command will be executed on the respective browser and the response will go back in the form of an HTTP response.


4. Browsers


Selenium supports multiple browsers such as Firefox, Chrome, IE, Safari, etc.


Demo

In real time, you write a code in your UI (say Eclipse IDE) using any one of the supported Selenium client libraries (say Java).


Example:


// System Property for IEDriver

System.setProperty("webdriver.ie.driver", "D:\\IE Driver Server\\IEDriverServer.exe");

// Instantiate a IEDriver class.

WebDriver driver=new InternetExplorerDriver();

driver.get("https://www.nextgenerationautomation.com");


Once you are ready with your script, you will click on Run to execute the program. Based on the above statements, the IE browser will be launched and it will navigate to Next Generation Automation website.


Once you click on ‘Run’, every statement in your script will be converted as a URL, with the help of JSON Wire Protocol over HTTP. The URL’s will be passed to the Browser Drivers. Here, in this case, the client library (Java) will convert the statements of the script into JSON format and further communicate with the IE Driver.


Every Browser Driver uses an HTTP server to receive HTTP requests. Once the URL reaches the Browser Driver, then it will pass that request to the real browser over HTTP. Once done, the commands in your Selenium script will be executed on the browser.

In the case of Chrome browser, you can write your Selenium script as shown below:



// System Property for ChromeDriver

System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");


// Instantiate a ChromeDriver class.

WebDriver driver = new ChromeDriver();

driver.get("https://www.nextgenerationautomation.com");


If the request is POST request, then there will be an action on the browser. If the request is a GET request then the corresponding response will be generated at the browser end. It will be then sent over HTTP to the browser driver and the Browser Driver over JSON Wire Protocol and sends it to the UI (Eclipse IDE).


So, that was all about Selenium WebDriver Architecture.


#NGAutomation