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:
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
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
- IBM Rational Functional Tester
- Testing Anywhere
- Visual Studio Test Professional
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.
Recorded test cases can be exported to various programming languages such as Java, C#, Python, Ruby, PHP and Perl.
Components of Selenium
Selenium is not just a single tool but a suite of products. It has four componentsSelenium 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 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
- Open a Mozilla Firefox browser.
- Type the URL http://seleniumhq.org/download/ in the browser and download the latest version as specified in the screenshot.
- 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.
- 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.
- 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.
- 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.
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.
- Open the Selenium IDE tool and enter the link for the application that is to be tested as shown in Figure 6.
- To open any link for the application that is to be tested, use the Open command and specify the link in the target value.
- 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.
- After specifying every command, the screen will look like whats shown is Figure 6.
This is how a test case can be created using the Selenium IDE.