Introduction To WebDriver And Its Comparison With Selenium RC – [Learn Selenium Basics]

In the past chapters, we learned about “How To Enhance A Script Using Selenium IDE?” and created simple tests using it. In today’s chapter, we are going to learn about Introduction To Selenium WebDriver which is an advanced tool and a mechanism to create more powerful test scripts than Selenium IDE.

Selenium WebDriver:

It is a web automation testing framework that assists to execute tests across various web browsers. Thus, it is a more flexible and powerful framework to write web testing automation scripts. Selenium WebDriver supports HTMLUnit and Firefox by default and other browsers such as Internet Explorer, Safari, PhantomJS, Opera, and Chrome with an additional component known as Driver Server.

Selenium WebDriver Image1
Click image to enlarge.

Browser Support by Selenium WebDriver:

Unlike Selenium IDE, WebDrivers can be used to write tests using various programming languages such as Java, .Net, etc. With the use of programming language, we need not to just rely on the in-built functions since we can leverage programming language features such as conditional operations (if-else or switch-case-default statements), looping (for-loop, while-loop), constant and variables declarations, etc. Following are the programming languages that are supported by the Selenium WebDrivers:

  1. Java
  2. .Net
  3. PHP
  4. Python
  5. Perl
  6. Ruby
Selenium WebDriver Supported languages
The programming language supported by Selenium WebDriver

Therefore, choose the programming language that you understand well while working with Selenium WebDriver. In this tutorial, we are going to use JAVA as a programming language and Eclipse as IDE.

WebDriver vs Selenium RC:

Selenium RC exists before Selenium WebDriver back in 2006. Both have the common features given as follows.

  • Test scripts can be written in different programming languages.
  • Tests can be executed across different web browsers.

Now the question should be, what is the actual difference? To understand that let’s take a look at Selenium RC architecture.

Selenium RC (Remote-Control) Architecture:

Selenium RC (remote control) is a testing framework or tool that assists in writing automated web application GUI tests in different programming languages such as JAVA, .NET, Perl, Python, etc. against any HTTP website via JavaScript-enabled browser. Selenium RC as two parts.

  1. A remote control server that launches and kills web browsers and behaves as an HTTP proxy for different web requests from them
  2. Client libraries that support different programming languages.

The following points to be remembered about Selenium RC’s architecture.

  • Before we can start actual testing, we need to launch a separate application called Selenium Remote (RC) Server.
  • From the architecture diagram, it is clear that the RC Server is a middle layer between our Selenium commands and the browser.
  • RC server injects a JavaScript program known as Selenium Core into the web browser when we trigger the actual web testing.
  • Through this injected JavaScript program, Selenium Core receives instructions by the RC Server from the program under test.
  • Upon receiving the instructions, Selenium Core executes these instructions as JavaScript command statements.
  • The browser receives the instructions from Selenium Core and relays its response to the Selenium RC Server.
  • Using the response received by the RC Server, the test results are displayed to the user.
  • The same cycle is repeated instruction by instruction until the entire test is completed.
Selenium RC
Selenium RC (Remote Control) Architecture

WebDriver Architecture

Comparatively, WebDriver architecture is simpler than Selenium RC architecture as explained above. Selenium WebDriver architecture has the following two parts.

  1. The browser is controlled by WebDriver at Operating System (OS) level, unlike RC Server.
  2. We require programming language’s IDE that has Selenium test commands and a web browser to run the website.
WebDriver
Selenium WebDriver Architecture

After discussing both the architectures, we can conclude that Selenium RC’s architecture is more complicated than Selenium WebDriver architecture.

Comparison between Selenium WebDriver and Selenium RC:

S. No. Factor WebDriver Selenium RC
1. Operating Speed WebDriver operating speed is faster than Selenium RC as it uses the web browser’s own engine to control it. Selenium RC has slow operating speed as compared to WebDriver as uses a JavaScript program known as Selenium Core which interacts with the browser and is indirect control.
2. Interactions with GUI elements Interaction of WebDriver is very realistic such as if any web page element is disabled that we cannot access and enter the value into it, a similar way WebDriver also cannot access that element. Interaction of Selenium RC is not realistic as it operates by JavaScript code which can access disabled elements from the web page and enter the value into it. Such features may end up giving inappropriate test results.
3. API Complexities WebDriver API commands are very simple, non-redundant and easy to understand. Selenium RC API is matured but has redundancies in commands which are sometimes very confusing while writing the test scripts. For example, testers are often get confused with the use type or typeKeys; and the use ofclick, mouseDown or mouseDownAt, etc.
4. Browser Support It supports a headless HTMLUnit browser. The term headless means that the browser is invisible to the user and it runs web tests on a virtual web browser which removes the overhead of waiting to load web page elements. It enhances the test execution speed. Selenium RC does not support a headless HTMLUnit browser. It requires the actually visible browser so that it can inject the JavaScript code to do the required tests.
5. Programming Languages Support It supports programming languages such as Java, .Net, PHP, Python, Perl, and Ruby. It also supports programming languages such as Java, .Net, PHP, Python, Perl, and Ruby.
6. Support for New web Browsers Webdriver default support is for HTMLUnit and Firefox web browser. It can support other browsers such as Safari, IE with the help of additional components known as Driver Server. Therefore, if there is a new browser that is launched in the market in the future then there will be a need to develop a new Driver Server in order to get support from WebDriver. With Selenium RC, as long as it can able to inject the JavaScript code or Selenium core for request and response it can support any web browser for testing.
7. Built-In Test Result Generator WebDriver does not have any kind of built-in test result generator and for test results, it relies on IDE’s output window. Selenium RC has an in-built test result generator that generates an HTML file of test results. RC has a pre-set format for this file. This file helps RC to prepare the test results.

 

Conclusion:

In this chapter we have discussed and Introduction To WebDriver and RC architecture and later compared their utilities as an automated web testing tool.


⇓ Subscribe Us ⇓


If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 

Leave a Comment

Share This Post