Introduction to Selenium: an open source web automation tool

3
20118

gearvisual

Selenium is a software testing framework for Web applications. One of its advantages is that you don’t have to know any test scripting language. Selenium has rivals too, the main one being QTP. This article is a primer on Selenium in its various avatars.

Selenium is the most popular open source automation testing tool for Web based applications. The reason behind its success is its compatibility with all available Web browsers. The major difference between HP’s QTP (Quality Test Professional) and Selenium is that QTP is used for automating desktop applications along with Web applications, while Selenium is used primarily for Web based applications. When it comes to handling the behaviour of various Web elements like properties, Selenium leads the race against QTP.

In this introductory tutorial, we will be exploring Selenium from the beginner’s viewpoint, starting with the very basics, and go on to learn more about its features and compatibilities.
So, as we said before, Selenium is the open source automation testing suite for Web based applications. It is considered a test suite rather than a tool because it supports multiple capabilities catering to various needs. The Selenium test suite comprises four components:

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

Right now, Selenium RC and WebDriver are collectively known as Selenium 2, while Selenium RC alone is known as Selenium 1.

Figure 1
Figure 1: The Selenium test suite

History
Let’s talk a bit about the developers behind this tool. Selenium is a collection of various tools, with contributions coming from many developers who have in the past worked to make it the most suitable test automation tool for Web based applications. The main credit goes to Jason Huggins for Selenium’s foundation. He started it way back in 2004 when he was an engineer with ThoughtWorks, and was working on one of the Web applications that required frequent testing. To tackle the repetitive manual tasks, he came up with a JavaScript code which could automatically control the browser’s actions. At that time, he named it JavaScriptTestRunner. After seeing its ability to handle browser components, he made the code open source so that others could also contribute, and named it Selenium Core. Later on, various developers kept adding their code to make it a complete test suite, i.e., what we see today. The other main contributors are Paul Hammant (Selenium RC), Patrick Lightbody (Selenium Grid), Shinya Kasatani (Selenium IDE), and Simon Stewart (WebDriver).

Table 1
Table 1: Choosing the right tool

Selenium IDE
Selenium IDE is the simplest tool in the Selenium test suite. It is a Firefox plug-in that you can install like all other plug-ins. However, it doesn’t give you many advanced features to tackle complex test cases but is suitable as a prototyping tool. You will not require any prior programming experience but awareness of HTML is helpful. You can export tests from here to Selenium RC and WebDriver.
The pros of Selenium IDE are:

  • Very easy to use and install
  • No programming experience is required, though knowledge of HTML and DOM is needed
  • Can export test cases to formats usable in Selenium RC and WebDriver
  • Has built-in help and a test results reporting module
  • Provides support for extensions

The cons are:

  • Available only in Firefox
  • Designed only to create the prototypes of tests
  • No support for iteration and conditional operations
  • Test execution is slow compared to that of Selenium RC and WebDriver
Table 2
Table 2: Browser and environment support

Selenium Remote Control (RC)
Selenium RC allows you to write automated Web application tests in compliant programming languages. It offers programming language options like Java, Ruby, Python, Perl, PHP or .NET.
The pros of this tool are:

  • Cross-browser and cross-platform
  • Can perform looping and conditional operations
  • Can support data-driven testing
  • Has a mature and complete API
  • Can readily support new browsers
  • Faster execution than the IDE

The cons are:

  • Installation is more complicated than with Selenium IDE
  • Requires users to have programming knowledge
  • Needs the Selenium RC server to be running
  • API contains redundant and confusing commands
  • Browser interaction is less realistic
  • Inconsistent results and uses JavaScript
  • Slower execution time than WebDriver
Table 3
Table 3: Advantages of Selenium over QTP

Selenium WebDriver
Selenium WebDriver itself is more robust than both RC and IDE. It uses a more stable approach to automate browser actions. Rather than calling any other external JavaScript, WebDriver directly interacts with the browser and its components. It supports the same programming languages as that of Selenium RC (Java, Ruby, Python, Perl, PHP or .NET).
The pros of WebDriver are:

  • Simpler installation than Selenium RC
  • Communicates directly to the browser
  • Browser interaction is more realistic
  • There’s no need for a separate component such as the RC server
  • Faster execution time than Selenium IDE and RC

The cons are:

  • Installation is more complicated than IDE
  • Requires knowledge of programming
  • Needs Selenium RC server to be running
  • API contains redundant and confusing commands
  • Browser interaction is less realistic
  • Inconsistent results and uses JavaScript
  • Slower execution time than WebDriver
Table 4
Table 4: Advantages of QTP over Selenium

Selenium Grid
This is used along with Selenium RC to allow the running of multiple parallel tests across different machines and browsers at the same time. Parallel execution means running different tests at once.
Table 1 indicates how you should go about choosing the most suited tool in Selenium for your needs.

Because of the architectural differences in various Selenium tools, each one supports different versions of a browser and operating systems. This is indicated in Table 2.
Tables 3 and 4 provide a comparison between Selenium and QTP.

So after a comparison, it is evident that QTP has more advanced capabilities in some areas while Selenium is better in the following areas.

  • Cost: Being open source, everyone is free to use it.
  • Flexibility: Wide support to various programming languages and browser versions.
  • Parallel testing: Something that QTP is not able to perform.

3 COMMENTS

    • Apologies for the typo. Here are few cons of the Selenium WebDriver:

      1. Demands higher technical competencies, I would say tool of choice for developers. QA team members need to learn programming.

      2. Need to work with many and connect third party frameworks (TestNG, Firebug etc) right from object identification, reporting, integrations with other ALM solutions etc.

LEAVE A REPLY

Please enter your comment!
Please enter your name here