DEV Community

Bethany Wilson
Bethany Wilson

Posted on

What is selenium webdriver and how it works?

Selenium WebDriver is one of the most important components of the “Selenium tool suite.” Selenium WebDriver is considered to be an advanced version of Selenium RC (Remote Control). The Selenium WebDriver architecture consists of four important components namely Selenium Client Library, JSON wire protocol over HTTP, Browser Drivers and Browsers. It is a set of open-source APIs through which it can easily interact with different web browsers and upon that the user actions can also be automated based on the browser that is being used. WebDriver has become a sort of de-facto standard for web automation. It provides multi-language support, multi-browser compatibility, faster execution etc., because of which it is considered to be in demand. In this article, you will get a brief idea about the working of Selenium WebDriver.

What is Selenium WebDriver?

It is a web framework through which cross-browser tests are executed. Web-based application testing is automated using this tool to verify whether it is performing as expected. Test scripts can be created by choosing a specific programming language. It can easily work with open-source APIs. The framework operates through accepting commands, then those commands are sent to a browser and finally the applications interact. Selenium WebDriver supports browsers such as Firefox, Chrome, Internet Explorer and Edge.

How Selenium WebDriver works?

There are three important steps that are required for making a Selenium WebDriver work effectively:

  1. JSON wire protocol is used to convert test commands into an HTTP request
  2. Before any test cases are executed, there is a driver which initializes the server
  3. The request is received by the browser through its driver.

Following is a simple example that explains the working of Selenium Webdriver:

Below is a code snippet:

WebDriver driver = new ChromeDriver ();
driver.get (https://www.anycompanyname.com)
As soon as the code has been written, the program is executed. Through the above code, the Chrome browser will be launched, which will in turn help navigate to the anycompanyname website.
Following is an explanation of what happens when you run the above code until the Chrome browser has been launched. After the execution of the program, each and every line of the code/snippet is transformed into a URL. This is made possible by JSON wire protocol over HTTP. Then, passing the URL to the browser drivers (in this example, it is ChromeDriver). At this point, the code is translated by the client library (Python in this example) into JSON format and then interacts with the ChromeDriver.

After JSON conversion, the URL looks like this:

https://localhost:8080/{“URL”:https://www.anycompanyname.com”}
In order to receive the HTTP requests, the HTTP server is used by every Browser Driver. Once the URL is received by the browser driver, the request is processed by passing it to the real browser over HTTP. Then, execution of all the commands in the Selenium scripts takes place.

Types of requests:

GET and POST are the two important types of requests.
If it’s a GET request, then it will result in generating a response at the browser end and it will be sent over to the browser driver over the HTTP platform. Eventually, with the help of JSON wire protocol, the browser driver is sent to the UI.

Following are the benefits of Selenium WebDriver:

• It supports various operating systems such as Mac, Windows, Linux, Unix etc.,
• It is compatible with various languages such as Perl, Java, Python, Ruby etc.,
• The execution of test scripts is carried out at a rapid pace
• It provides a more concise API (Application Programming Interface)
• It provides compatibility with AndroidDriver, HtmlUnitDriver and iPhoneDriver.

Conclusion: If you are looking forward to implementing Selenium automation testing services for your specific project, then do get connected with a remarkable software testing services company that will provide you with a solid testing approach that is in line with your project specific requirements.

About the author: I am a technical content writer focused on writing technology specific articles. I strive to provide well-researched information on the leading market savvy technologies.

Top comments (0)