Review of Selenium - An Automated Testing Tool
Monday December 5, 2011
In this post, we aim to help you understand one of the popular automated testing tools – Selenium.
Selenium is a set of tools that when put together can automate web UI testing in the most efficient manner. It is an opensource automated testing framework that can be used to write and execute test cases on a variety of web browsers such as Safari, Firefox, Internet Explorer and Opera.
These set of tools that make Selenium a versatile testing tool include:
- Selenium Integrated Development Environment (IDE)
- Selenium Remote Control (RC)
- Selenium WebDriver
- Selenium Grid
This is the Integrated Development Environment that enables tester to manually record the test steps and play them back on the browser to run the test automatically. The tester can edit and debug the tests on Selenium IDE as well.
For those of you who are wondering what is special about this tool, here is the deal - it is not just a record and playback tool but a full-fledged development environment, which even lets you create/edit your scripts by typing in the commands (in Selenese).
Some features of Selenium IDE that makes it stand out are:
- The record and playback functionality is as easy as it can ever get.
- It has an auto complete capability for all the Selenium commands (Selenese).
- The tester can debug using the IDE itself by setting breakpoints (both start and stop).
- It gives the tester a variety of formats to save the tests in –HTML, Ruby etc.
- The IDE supports intelligent field selection for IDs, names and XPaths.
- The tester can choose automatic assertion of every page’s title.
- It also provides support for Selenium user-extensions.js file.
A newly introduced feature is the ease of customization through plugins that give way to:
- Custom formats
- Export Capabilities
- Adding new functionalities to the API
- Editing the existing functionalities
- Plugin update.rdf files can be hosted
- Adding new locator strategies are going to be released soon
Some noteworthy commands and functionalities in Selenium IDE:
- The ‘AndWait’ command usage when navigation from one page to another happens prevents the test case from failing due to synchronization issues.
- The ‘WaitFor’ command usage when data is fetched from the server is a better alternative to AndWait command (since the page is not refreshed as such) or pausing the test.
- The Base URL field can be used to run the same test across different domains.
- Locating, asserting and verifying of elements on a web page can be handled differently according to the testing requirements.
- The ‘Echo’ command enables you to print text to the output of every test thus providing progress notes on the testing console while the testing is on.
Selenium RC aka Selenium 1
For those of you who would rather write and run tests written in any one of the programming languages - .Net, Java, Perl, PHP, Python and Ruby, Selenium Remote Control is your approach to do so.
Selenium RC provides testers with a more flexible but complex platform to create and run browser tests. Each of the above-mentioned programming language has an associated client driver that needs to be installed in order for tester (test cases/browser) to communicate with the server.
With Selenium RC, the testers can either:
- Write test cases from scratch on any of the programming languages supported.
- Capture tests using Selenium IDE and then export them to scripts in any of the programming language that will create a test case skeleton to proceed with.
Some noteworthy features of Selenium RC:
- The Selenium server is capable of launching and killing browsers.
- The Selenium server interprets and runs Selenese commands that are written in the test program.
- The Selenium RC automatically bundles the Selenium core into the respective browser.
- The server also acts as HTTP proxy server which verifies the messages passed between the application that is being tested and the browser.
- Each programming language has an associated client driver that acts as an interface between the language and the server.
- Selenium RC allows the tester to create customized reports with the test run results using the features of your chosen language.
- By combining a programming language within Selenium, it is possible to iterate the same search result for a more flexible solution rather than repeating it over n number of times.
- It is possible to handle exception and continue to run the test script with Selenium RC combined with a language. For e.g. despite absence of an element on a web page the test script can be coded to continue.
- It is possible to run Selenese HTML tests with the Selenium server by passing the HTML to the server’s command line. The results of these tests will be saved in a HTML report.
- ‘-log’ command can be used to record the debugging information that is reported by Selenium server into a text file.
With Selenium Web driver (Selenium 2) being released, the usage of Selenium 1 seems to be decreasing. However, Selenium 1 is still largely supported in maintenance mode. Also, Selenium 1 does provide a few features that are yet to be implemented in Selenium 2.
Selenium Web driver aka Selenium 2
This is the newest addition to the Selenium set of tools, the main objective of which is to provide the testers with a simpler and more flexible programming interface. In short, a beneficial merger of WebDriver with Selenium is what Selenium 2 is about.
Some features worth mentioning about Selenium Web Driver are:
- The testers are provided with an object-oriented interface that supports more number of browsers.
- The exclusive usage of Selenium WebDriver will mean Selenium server need not be installed.
- Selenium server is needed if Selenium Grid (discussed below) is used for distributing test over more than one machine.
- Wherever possible, the Selenium WebDriver makes use of native events to interact with web pages.
- Advanced user interactions APIS are provided by Selenium WebDriver to help you generate more complex tests.
- Full support extended from various browser vendors such as Google, Mozilla etc. thus enabling the tests to run fast and reliably on these browsers.
When Selenium Grid is used in conjunction with Selenium RC, the same tests can be run on different servers at the same time. Also, this specific tool enables the Selenium RC to support large test suites thus supporting scalability.
Since Selenium 2 is released, built-in grid functionality has been incorporated into the Selenium server itself.
TestingWhiz, an automated testing tool, aims to minimize the amount of manual work involved in test execution and gain higher coverage with large number of test cases which lead to cost savings and productivity gains.
More Selenium Resources
- Selenium IDE
- How to install Selenium RC and each of the client libraries
- How to migrate from Selenium 1 to Selenium 2
- Simon Stewart presenting WebDriver at GTAC 2007
- Selenium Grid
- Documentation on Selenium
To experience Selenium Resources, download the Enterprise Version of TestingWhiz now!