Getting Started with Selenium Webdriver

What is WebDriver?

Selenium WebDriver is a web framework that permits you to execute cross-browser tests. It is an interface to write instruction sets that can be run interchangeably in many browsers.

WebDriver Architecture:

WebDriver is made up of following components:

– Language Bindings: Selenium provides support to multiple libraries such as Ruby, Python, Java, etc as language bindings.

– JSON Wire Protocol: 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.

– Browser Drivers: Selenium provides drivers specific to each browser and without revealing the internal logic of browser functionality, the browser driver interacts with the respective browser by establishing a secure connection. These browser drivers are also specific to the language which is used for test case automation like C#, Python, Java, etc.

– Real Browsers: Selenium provides support for multiple browsers like Chrome, Firefox, Safari, Internet Explorer etc.

When a test script is executed with the help of WebDriver, the following tasks are performed in the background:

  1. An HTTP request is generated and it is delivered to the browser driver for every Selenium Command.
  2. The HTTP request is received by the driver through an HTTP server.
  3. All the steps/instructions to be executed on the browser is decided by an HTTP server.
  4. The HTTP server then receives the execution status and in turn sends it back to the automation scripts.

Example:

Scenario – Navigate to https://qascript.com

WebDriver driver = new ChromeDriver();
driver.get("https://qascript.com");

When you execute this script, every statement is converted as a URL, with the help of JSON Wire Protocol over HTTP. The URL’s is passed to the Browser Drivers (Chrome Driver in the above example). Once the URL reaches the Browser Driver, then it will pass that request to the real browser over HTTP. Once done, the commands in the script will be executed on the browser.

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 (IDE).

 

Share

Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

1 Response

  1. First time visiting your website, I really like your site!

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!