Selenium: A Popular Software Testing Tool You Can Rely On

1
6246
gear and communicate
For the software enthusiast, this article begins with an overview on software testing. The various types of testing and the many software testing tools are enumerated, and then the author goes into detailed discussion on the free and open source automation testing tool, Selenium.

Software testing is a process of evaluating a system or its components to find out whether the specified requirements are met. It can also be referred to as a system to identify any gaps, errors or missing requirements. It comprises verification and validation of the software product. This process starts from the beginning of the software development lifecycle (SDL) till it is delivered to the customer.

The purpose of software testing is to deliver a higher quality of product. If the product produces an error at a later stage, then it becomes costly to remove it. Software testing has the potential to save money and time by identifying problems early and delivering a defect-free product.
It has three main objectives:

  • Verification: This process confirms that the software meets its technical specifications.
  • Validation: This process confirms that the software meets the business requirements.
  • Defect: This detects any differences between the expected and actual results.

Software testing can be done in various ways and is broadly divided into two types:

Figure 1 Types of Software Testing
Figure 1: Types of Software Testing
Figure 2 Selenium Components
Figure 2: Selenium’s Components

Manual testing: This type of testing involves software developers running tests manually.
There are several stages at which manual testing can be done. These are:

  • Unit testing
  • Integration testing
  • Software testing
  • Functional testing
  • Non-functional testing
  • System testing
  • User acceptance testing
  • Release or deployment testing
Figure 3 Selenium Download Page
Figure 3: Selenium Download Page
figure 4
Figure 4: Selenium IDE Menu-Items

Automation testing: This type of testing is done using automation tools. It reduces the overall effort and time required in regression testing and speeds up the overall testing process. Various automation tools can be used for this. Some of these tools are:

  • HP Quick Test Professional
  • Selenium
  • IBM Rational Functional Tester
  • SilkTest
  • TestComplete
  • Testing Anywhere
  • WinRunner
  • LoadRunner
  • Visual Studio Test Professional
  • WATIR

Table

Introducing Selenium
With the dynamic growth in the IT industry, there has been an increase in testing costs. So, organisations have started choosing open source automation tools rather than their commercial variants. Automation tools, as their name suggests, provide features for automating the testing of software and Web applications. Various types of automation testing tools are available for the different tests required like regression, performance or functional testing.
One of the most commonly used automation tools is Selenium. It is one of the best options to test Web applications, and can be used for automating the testing of both the GUI as well as the features. It can also be used as a unit testing tool for JavaScript. It provides a record/playback facility to authorise the tests without knowing the test scripting language (Selenium IDE). It is implemented as a Firefox extension, which allows replaying, recording and editing test cases in Firefox.
Selenium allows testers and developers to develop test scripts to drive the browser. It prevents future regression of code; hence, it is popular. It can work on any browser that supports JavaScript, since it has been built using JavaScript.
Recorded test cases can be exported to various programming languages such as Java, C#, Python, Ruby, PHP and Perl.

figure 5
Figure 5: Selenium IDE
figure 6
Figure 6: Sample test case execution on selenium IDE

Components of Selenium
Selenium is not just a single tool but a suite of products. It has four components—Selenium IDE, Selenium Grid, Web Driver and Selenium RC. Selenium RC and Web Driver have been merged to form a framework known as Selenium 2.
Selenium IDE: Selenium IDE is an integrated development environment for Selenium tests. It was developed by Shinya Kasatani. It allows you to use Selenium Core without having to copy it onto the server.
Selenium Core is a JavaScript module that allows Selenium to drive the browser. It can interact with Document Object Model (DOM) using JavaScript calls. Scripts are recorded in Selenese, a special scripting language for Selenium. It provides commands for performing actions in Web browsers and for retrieving data from multiple pages.
Selenium RC: This is a server written in Java, which accepts commands for the browser via HTTP. It makes it possible to write the tests for Web applications in any programming language. When using Selenium, a core user has to install the whole application under test alongwith the Web server on the local computer. So a server has been created by an engineer named Paul Hammant, which acts as a proxy to trick the browser into considering the Selenium core and Web application that is being tested as coming from the same domain. This is known as Selenium RC (remote control) or Selenium 1.
Selenium Web Driver: This is the successor to Selenium RC. It is the first cross-platform framework for testing that controls the browser from the OS level. It was created by Simon Stewart in 2006. It accepts commands, sends them to a browser and retrieves the result. It does not require any special server to execute tests. Selenium Grid can be used with Web Driver to execute tests on remote systems. At present it is fully implemented and supported in Ruby, Python, C# and Java.
Selenium Grid: This is a server that allows tests to use Web browsers running on remote systems. In this, one server acts as the hub. The tests contact the hub to obtain access to browsers. The hub consists of lists of servers that provide access to browsers (i.e., Web Driver nodes). It allows the running of tests in parallel on multiple machines, and the management of different versions and configurations of browsers, centrally. This helps to spread the load of testing across several machines by running the tests across different platforms or operating systems.
Installation of Selenium

  1. Open a Mozilla Firefox browser.
  2. Type the URL http://seleniumhq.org/download/ in the browser and download the latest version as specified in the screenshot.
  3. When the download link is clicked, Firefox will enable a pop-up that asks if you want to allow Mozilla Firefox to install Selenium IDE or not. Click the Allow button.
  4. Firefox will automatically install the Selenium IDE software. After completing the installation, it will show one pop-up that states the Selenium IDE installation has been completed. Now restart the browser to use Selenium IDE. Click the Restart Now button.
  5. Firefox will restart automatically. Now click on the Tools menu list displayed on top to see the Selenium IDE option as shown in Figure 4.
  6. Click on the Selenium IDE option. This will launch the Selenium IDE software window.
    This is the screen for Selenium IDE, where tests can be recorded, replayed and edited.

Table 1

Creating the first test script using Selenium
We will be creating a test for clicking on the Search option to open the Search page in the Clean-clouds.com application.

  1. Open the Selenium IDE tool and enter the link for the application that is to be tested as shown in Figure 6.
  2. To open any link for the application that is to be tested, use the Open command and specify the link in the target value.
  3. Click on the Search option, write a new command and specify the ID of the target in the target value. This ID can be obtained with the help of Firebug, by clicking on a particular target, which is the Search option in this case.
  4. After specifying every command, the screen will look like what’s shown is Figure 6.

This is how a test case can be created using the Selenium IDE.

Table 2

References
[1] http://automationinqtp.blogspot.in/2013/01/qtp-vs-selenium.html
[2] http://blog.testing-whiz.com/2013/06/comparing-qtp-selenium-and-testingwhiz.html
[3] http://kedar.nitty-witty.com/blog/selenium-vs-qtp-differences-usage-quick-reference
[4] http://docs.seleniumhq.org/docs/01_introducing_selenium.jsp
[5] http://www.xoriant.com/blog/software-testing-and-qa/selenium-open-source-test-automation-tool-an-overview.html
[6] http://www.aspiresys.com/WhitePapers/QTPvsSelenium.pdf

1 COMMENT

  1. Thanks. Wonderful article to understand the Devops which is future. Two Questions if you can help please.
    1. Early automation sounds good but in actual, while requirements are changing frequently, there will be too much rework in updating the automation scripts.
    Generally automation is advisable when system is matured. How beneficial it would be ?
    2. How can we automate test cases for first sprint when application is not ready ? To achieve this, I think FSDs should be detailed enough but again that is difficult when requirements are changing frequently.

LEAVE A REPLY

Please enter your comment!
Please enter your name here