Quick Review of Selenium WebDriver

Knoldus Blog Audio
Reading Time: 3 minutes

What is Selenium

Selenium is a software testing framework for the web that facilitates the automation of browsers. The Selenium project produces various tools for automation testing such as Selenium IDE, Selenium Remote Control (RC), Selenium Grid, and Selenium 2.0 & WebDriver.

Learning all the tools will give you many different options for approaching different automation problems.

The entire suite of tools results in a rich set of testing functions specially geared to the needs of testing of web applications of all types.

Selenium Grid

Selenium Grid is a tool used for the parallel execution of selenium scripts. For example, if we have a single machine and to this single machine, we can connect multiple machines with multiple operating systems so that we can run our test cases parallel across different machines which can save our time.

Selenium IDE

Selenium IDE is a tool which basically runs only on Chrome and Firefox browsers. It generates no reports and cannot execute multiple test cases. For example, if we have 5000 test cases then IDE cannot work, it’s not a robust tool to execute multiple test cases. It cannot generate logs.

Selenium RC(Remote Control)

Selenium RC, which is deprecated now in the present market can write dynamic scripts that could work on multiple browsers. The best part is that Selenium RC, we had to learn a programming language like Python, C#, Ruby, Java to execute Selenium RC.

Selenium WebDrivers

Selenium web driver is a tool that provides a user-friendly interface that you can use and explore easily. It is not tied with any framework. So, it allows you to integrate with testing frameworks like JUnit and TestNG.

WebDriver is not a migration from RC to WebDriver, it was an entirely different tool than RC. Where each has its own commands. It can also make dynamic scripts and could work on multiple browsers.

Selenium WebDriver Architecture

Before starting with Selenium WebDriver Architecture, we need to know few concepts if we want to understand the working of Selenium WebDriver.

Components :

  • Selenium Client Library: Selenium supports multiple libraries like Java, Python, Ruby, etc. Selenium developers have developed language bindings to allow selenium to support multiple languages. 
  • JSON Wired Protocol over HTTP Client: Each browser contains a separate browser driver that communicates with the respective browser without revealing the internal logic of browser functionality. When a browser driver receives any command then it will be executed on the respective browser and the response will go back in the form of an HTTP response.
  • Selenium API:   API serves as an interface between the software program and facilitates their interaction. API is a software to software interaction which means API works from software to software.
  • Remote WebDriver: It is an implementation class of the WebDriver interface that a test script developer can use to execute their test script through the WebDriver server on the remote machine.
  • Browsers:
    • Selenium supports multiple browsers such as Firefox, Chrome, Safari, etc.
For example:-
WebDriver driver = new FirefoxDriver();
           driver.get(https://www.flipkart.com);

Based on this code, Firefox will be launched and it will navigate to the website.

  • When you click on Run, every statement in your script will convert as a URL with the help of JSON Wire Protocol.
  • The URL’s will be passed to the Browser Drivers. Here in this case the client library will convert the statements of the script to JSON format and communicate with the FirefoxDriver.

 URL looks as shown below.

http://localhost:8080/{“url”:”https://www.flipkart.com”}

  • Now, Once the URL reaches the Browser Driver, then the Browser Driver will 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 a POST request then there will be an action on the browser.
  • When the request is a GET request then the corresponding response will be generated at the browser end and it will be sent over HTTP to the browser driver and the Browser Driver over JSON Wire Protocol and sends it to the UI.

This is a quick overview of Selenium WebDriver and how it works internally.

Conclusion

So, as a result, we have seen the features of Selenium WebDriver in this blog. Selenium WebDriver is one of the most powerful tools in the Selenium toolkit. It is an extended version of Selenium RC. WebDriver also has supported many platforms and browsers.