Selenium WebDriver Architecture: In this post, we are going to discuss the internal implementation of selenium Webdriver or you can say Selenium WebDriver Architecture. like all, we know that selenium is mostly used to interact with the web browsers and also for test end to end scenario of a web application.
Selenium Is consist of:
- Selenium IDE
- Selenium WebDriver
- Selenium Grid
Selenium IDE: Selenium IDE (Integrated Development Environment) is a Firefox plugin. It is the simplest framework in the Selenium. By using Selenium IDE we can record and playback the scripts and also we can create scripts using Selenium IDE, but there are few restrictions that why we need to use Selenium RC or Selenium WebDriver to write more advanced test cases.
Selenium RC: When Selenium first introduced as Selenium 1 that time Selenium RC was the main Selenium project. Selenium RC is still widely supported (in maintenance mode). Its dependence on JavaScript for automation and also supports various other languages like Java, Javascript, Ruby, PHP, Python, Perl, and C#. we can also use almost most of the browsers. But when Selenium 2 is released after that uses of Selenium RC goes down and now it is officially deprecated.
Selenium WebDriver: Selenium WebDriver is nothing but a browser automation framework that receives the command and sends those commands to the browsers and all this happening through the browser-specific driver(Firefoxdriver, IEDriver, Chromdriver, etc). It controls the browser by directly communicating with it. Selenium WebDriver widely supports most scripting languages like Java, C#, PHP, Python, Perl, Ruby.
Selenium Grid: It is a tool used with Selenium RC to run tests parallel in two different machines and browsers. By this, we can run multiple tests on different machines, browsers, and in a different configuration at a time. in Selenium Grid one machine is called a hub and another called node.
Selenium WebDriver API: First we have to know what is API and What is the use of API. API is a set of rules and specification which is followed by software programs to communicate with each other. it behaves like an interface between different software programs. in the same way, UI is an interface between humans and computers. Similarly, Selenium WebDriver API is heps in the communication between the browser and languages.
We are writing the test script using a programming language like Java, C#, Python, etc for automating web application but the browser doesn’t understand those languages.
Components of Selenium Architecture:
- Selenium Client Library
- JSON Wire Protocol over HTTP
- Browser Drivers
- Browsers
Selenium Client Library: As we all know that selenium is available in different flavor like we can use selenium with scripting languages like Java, Ruby, Python, etc. we are able to use selenium with so many another scripting because selenium developers developed language binding which allows selenium to support multiple languages. you can get a selenium library for each language here.
JSON Wire Protocol over HTTP: It is used to transfer data between server and client on the web. JSON Wire Protocol is a REST API which transfers the information between Http Server ( FirefoxDriver, ChromeDriver, and IEDriver, etc.. ) like.
Browser Drivers: for automated the browser, each browser developers have provided specific drivers. that driver communicates with the browsers without revealing the internal logic of browsers functionality. When we execute a script according to that command is deliver and executed in the respective browser and response is received in the form of HTTP Response.
Browsers: Selenium supports almost all popular browsers like firefox, chrome, safari and internet explorer, etc.
Whatever the commands issued in the code will be interpreted into Webservice methods (JSON Wired Protocol), and the Remote Driver will receive the HTTP request (commands) and execute them in the browser then send the response back.
Example:
Let’s take the sample code and see how the data flows between Client Bindings, Server.
driver.get("http://www.google.com");
The client library, as soon as it receives the above command, will convert it to the JSON format (shown below) and communicate with the Firefox Driver/Remote WebDriver.
http://localhost:7705/ { "url": "http://www.google.com" }
Firefox Driver will speak to the Firefox browser natively, and then the browser will send a request for the asked URL to load.
Leave a Reply