Automation Testing Using Selenium WebDriver

s6

Automation testing is a Software testing technique to test and compare the actual outcome with the expected outcome. This can be achieved by writing test scripts or using any automation testing tool. Test automation is used to automate repetitive tasks and other testing tasks which are difficult to perform manually

Introducing Selenium

Selenium is a set of different software tools each with a different approach to supporting test automation. The entire suite of tools results in a rich set of testing functions specifically geared to the needs of testing of web applications of all types. These operations are highly flexible, allowing many options for locating UI elements and comparing expected test results against actual application behavior. One of Selenium’s key features is the support for executing one’s tests on multiple browser platforms.

What is Selenium?

Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. It is quite similar to HP Quick Test Pro (QTP now UFT) only that Selenium focuses on automating web-based applications. Testing done using Selenium tool is usually referred as Selenium Testing.

Selenium is not just a single tool but a suite of software’s, each catering to different testing needs of an organization.

It has four components:

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • WebDriver
  • Selenium Grid

s1

Selenium Integrated Development Environment (IDE)

Selenium Integrated Development Environment (IDE) is the simplest framework in the Selenium suite and is the easiest one to learn. It is a Firefox plugin that you can install as easily as you can with other plugins. However, because of its simplicity, Selenium IDE should only be used as a prototyping tool.

Selenium Remote Control (RC)

Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool that allowed users to use a programming language they prefer.

Selenium Grid

Selenium Grid is a tool used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time. Parallel execution means running multiple tests at once.

What is WebDriver?

WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox, Chrome (unlike Selenium IDE).

WebDriver also enables you to use a programming language in creating your test scripts (not possible in Selenium IDE).

You can now use conditional operations like if-then-else or switch-case. You can also perform looping like do-while.

s2

Programming languages supported by WebDriver:

Following are the features:

1. WebDriver Architecture

s3

  • It controls the browser from the OS level

2. Speed

WebDriver is faster since it¬†speaks directly to the browser uses the browser’s own engine to control it.

3. Real-life Interaction

WebDriver interacts with page elements in a more realistic way. For example, if you have a disabled text box on a page you were testing, WebDriver really cannot enter any value in it just as how a real person cannot.

4. API

Most of the time, testers are confused whether to use type or typeKeys; or whether to use click, mouseDown, or mouseDownAt. Worse,¬†different browsers interpret each of these commands in different ways too! WebDriver’s API is does not contain redundant and confusing commands.

5. Browser Support

WebDriver can support the headless HtmlUnit browserHtmlUnit is termed as “headless” because it is an invisible browser – it is GUI-less. It is a very fast browser because no time is spent in waiting for page elements to load. This accelerates your test execution cycles.

Example:

In real time, you write a code in your UI (say Eclipse IDE) using any one of the supported Selenium client libraries (say Java).

Here you can see, I am trying to launch Chrome browser and also hit the URL- http://click2cloud.com/ using Selenium WebDriver.

s4

After running the above script we can see the result as below.

s5

Advantages

  • Selenium is an Open Source Software.
  • Selenium supports various programming languages to write programs (Test scripts)
  • Selenium supports various operating systems (MS Windows, Linux, Macintosh etc‚Ķ)
  • Selenium supports various Browsers (Mozilla Firefox, Google Chrome, IE, Opera, Safari etc‚Ķ)
  • Selenium supports Parallel Test Execution.
  • Selenium uses less Hardware resources.

Limitations

  • It supports Web based applications only.
  • Difficult to use, takes more time to create Test cases.
  • Difficult to Setup Test Environment when it compares to Vendor Tools like UFT, RFT, Silk Test etc‚Ķ
  • Limited support for Image Testing.
  • New features may not work properly.
  • No Test Tool integration for Test Management, no Built-in Reporting facility.

Summary

WebDriver, the newer breakthrough that allows your test scripts to communicate directly to the browser, thereby controlling it from the OS level.

 

Leave a Reply