Selenium Webdriver API helps in communication between languages and browsers. Selenium supports several programming languages like Java, C#, Python etc., and additionally, it supports multiple browsers like Google Chrome, Firefox, Internet Explorer etc. Every browser has a totally different logic of performing actions like loading a page, closing the browser etc. Selenium WebDriver architecture.
There are four components of selenium Architecture:
Selenium client Library
JSON Wire Protocol over communications protocol
Browser Drivers
Browsers
Selenium client Libraries/Language Bindings:
Selenium supports multiple libraries like Java, Ruby, Python, etc., selenium Developers have developed language bindings to permit selenium to support multiple languages. cross-check selenium Libraries within the official website.
2. JSON WIRE PROTOCOL Over HTTP Client:
JSON stands for JavaScript Object Notation. it's used to transfer data between a server and a client on the net. JSON Wire Protocol is a REST API that transfers the data 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 a various browser while not revealing the interior logic of the browser’s practicality. once a browser driver has received any command then that command is executed on the various browser and therefore the response can return within the kind of communications protocol response.
4. Browsers:
Selenium supports multiple browsers like Firefox, Chrome, IE, Safari etc.,
Let’s see how selenium WebDriver works internally. 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:
WebDriver driver = new FirefoxDriver();
driver.get(https://intellipaat.com/);
Once you're prepared along with your script, you'll click on Run to execute the program. based on the above statements, the Firefox browser will be launched and it'll navigate to Intllipaat's website.
Here we tend to see what is going to happen internally once you click on Run until the launch of Firefox browser.
Once you click on Run, each statement in your script will be converted as a URL with the help of JSON Wire Protocol over communications protocol. The URL’s are passed to the Browser Drivers. (In the above code, we took FirefoxDriver). Here in our case the client library (java) will convert the statements of the script to JSON format and communicates with the FirefoxDriver. URL looks as shown below.
http://localhost:8080/{"url":"https://intellipaat.com/"}
Every Browser Driver uses an HTTP server to receive HTTP requests. Once the URL reaches the Browser Driver, then the Browser Driver can pass that request to the real browser over HTTP. Then the commands in your selenium script will be executed on the browser.
If the request is POST request then there'll be action on browser
If the request is a GET request then the corresponding response is going to be generated at the browser end and it'll be sent over communications protocol to the browser driver and the Browser Driver over JSON Wire Protocol and sends it to the UI (Eclipse IDE).