Introduction to Selenium WebDriver

 

Selenium WebDriver one of the most key component of SELENIUM Releases and on which current Automation industry totally rely on, specifically if we say “Open Source Community”.

What is WebDriver in simple and easy language if we say then “It is an API that’s easy to explore and understand, which help us to make our tests easier to read and maintain.” WebDriver is not linked to any kind of Test Framework or Tool and this makes this API more useful as we can use the same as per our needs or knowledge of other integration open sources like JUNIT, TestNG etc.

  • A well designed Object Oriented API that provides improved support for web-app testing problems.
  • Supports dynamic web pages where element of a Page may change without the Page itself being reloaded.
  • All the limitations of SELENIUM RC rectified in this Selenium WebDriver

 

Selenium RC Limitations

  1. Work using Java script injection leads to same origin policy issues. WebDriver overcomes this limitation by having driver for each browser.
  2. RC means Remote Control, while executing tests using Selenium RC it is obvious to have Selenium RC Server between Application under test & Test Automation Suite. This methodology of Client Server architecture of Selenium RC makes it slower then Selenium Web Driver.
  3. Redundancy of commands
  4. RC cannot support headless browser but WebDriver can.

 

WebDriver Architecture

  • WebDriver implemented on Layered Design, the idea behind this implementation is more and more usage of WebDriver for automation and this could be possible by fitting best fit languages.
  • Implementation of WebDriver is that each browser has a language that is most natural to use when attempting to drive it. Drivers are built as per the best fit language and we can just see the wrapper around them.
  • We can say that for any of browser driver if any of the features works there in one binding language then it should be easy to add support to other binding languages also.
  • Web Driver is a compact Object Oriented API which can directly interacts with the Application under tests.
  • WebDriver utilizes the browser native compatibility to automation without using any peripheral entity.

WebDriver_1

 

 

Features of WebDriver

1) “Interface WebDriver”, which represents an idealized web browser used for testing. Three categories of methods in this class.

  • Control to browser
  • WebElements selection
  • Debugging

2) We discussed above about language bindings with browsers and it is just a thin wrapper which is exposed for us to write code as per our needs. This leads WebDriver to support “Multiple Languages” as well as “Multiple Support Browsers” which means that if any API supports multiple languages then this automatically leads to “Multiple Platforms”.

 

Multiple Languages Binding SUPPORT

WebDriver_2

 

Multiple Browsers SUPPORT

WebDriver_3

 

Multiple Platforms SUPPORT

WebDriver_4

 

Speed difference between RC and WebDriver

WebDriver one to one communication with “Application under Test” makes it faster than Remote Control as RC creates one more interface between communications which is RC Server makes it likes Client Server Communication. Snapshot below:-

WebDriver_5

 

 

WebDriver Existence in package org.openqa.selenium

org.openqa.selenium: The global package of Selenium which we import in our program every time when it is needed to use WebDriver. For reference, please see “org.openqa.selenium” mind map below :-

WebDriver_6

WebDriver: Is an interface comes under this package of Selenium and a sub interface of “SearchContext”. “SearchContext” consists of “WebDriver” & “WebElement” as a sub interfaces.

 

 

WebDriver Interface

Let’s see what all WebDriver contains, for example: – What is “FirefoxDriver”: is a WebDriver which is used to interact with WebApps. So, this means that all the drivers should have all the implementations which are contracted in the WebDriver interfaces and all the Drivers can be called as WebDriver. See Figure below: –

WebDriver_8

  • At high level if we can say that Driver means as per the selection of the Explorer driver will be selected and Driver will be used to interact with Web Page.
  • Web Page composed of Web Elements and these Drivers’s will communicate with the Web Page.
  • For communicating with Web Page means communication with Elements present on the Web Page like for example: “Textboxes”, Buttons”, “Links” etc. “WebElement” a sub interface of “SearchContext” comes into picture. Let’s see this Interface also (Methods name and description in the table below).

WebDriver_9

Above table is providing us all the methods which we can use to interact with WebElements on Web Page but now for performing any of the operation on Web Element, we need to find element first on Web Page as per the above table and method findElement(). For finding element on Web Page, We need address/locator of the element and we can achieve this.

 

In detail below that what all WebDriver comprises of.

WebDriver_10

 

Highlights

  • WebDriver: One of the most core component from Selenium
  • WebDriver: With vast features where driver covers all the features and properties of explorers
  • WebDriver: Gives us the opportunity to write once and execute on multiple platforms
  • WebDriver: Provides speed to Selenium architecture where communication with Application under Test becomes faster
  • WebDriver: Despite of working on any language or environment you need not to learn anything new it is just grab the knowledge and start producing results
  • WebDriver: Gives opportunity to explore something from core and can contribute from scratch till end in Automation process
  • WebDriver: Introduce AndroidDriver and IphoneDriver to explore Mobile world

 

External Reference: – Thanks to “SELENIUMHQ.ORG”, for giving us the opportunity to explore Selenium thoroughly.

Happy Learning and Research further ………………………   Shrivastava Ankur

navigate-right-icon