Introduction
Within the software industry, once a
product reaches the stable manual testing phase, every organization usually
thinks of automated testing to save on the costs involved in manual testing.
Since testing cost is an important factor for any project, organizations have
started preferring open source test automation tools (which have reached a
stage where they now rival the commercial ones) instead of investing in costly
commercial testing tools. With no licensing costs, open source automation testing
tools provide competitive features for automating the testing of software
applications as well as Web portals.
A variety of open source automation
testing tools is available for almost all types of testing such as functional,
Web, UAT, regression, performance etc. Because of the extent to which these
open source tools have matured, it’s time to think about them and have them in
your QA automation kit. There are also various open source tools available to
support the different testing types such as White Box Testing (Unit Testing,
for e.g., using JUnit) and Black Box Testing (system/regression testing, for
e.g., using Selenium, Sahi, Watir, TestMaker, LogiTest, TestGen4J, FitNesse
etc).
The scope of this blog is to cover the basic flow for one
of these open source Web testing automation tools – Selenium.
Why Selenium?
Selenium is probably the best option for automated testing
of Websites today. It is becoming increasingly popular and it is the first
choice of automation testers as well as organizations for automating the
testing of Web-based applications for both the GUI as well as the
functionality. Selenium can also be used as a
unit testing tool for JavaScript. We at Xoriant have been working on
Selenium for automating the testing of Web sites developed using AJAX for the
pharmaceuticals and travel industries. The following graph shows the popularity
of Selenium along with other open source automation testing tools.
Selenium Test Package
Selenium is a package of various test components which consists of the following three major tools. Each one has a specific role in aiding the development of test automation for a Web application.- Selenium IDE – A Firefox extension to record test cases and suites.
- Selenium RC – Used to run tests on different browsers and systems.
- Selenium Grid – Runs multiple instances of Selenium RC at once.
- Qualitia and Tellurium – A wrapper for the Selenium engine.
Selenium Modes:
Bases on the components Selenium has following three modes for executing the test cases and test suites:- Record-Playback mode (Selenium IDE):
- Selenium Remote Control (RC) Mode
- Test Runner Mode
Testing AJAX with Selenium
Selenium IDE – Recording and updating a scriptSelenium IDE is the FireFox Add-on provided by the Selenium group. This is very simple and easy to use add-on so that non-programmers can record and create the test scripts for automating web components. These automated test scripts are used as Selenium RC test cases by choosing the language code. i.e. Selenium IDE makes easier to create Selenium RC test cases. (Install Selenium IDE and Selenium RC from Selenium download page).
Selenium IDE is used for:
- Recording and updating the test cases or write them manually in table tab.
- Creating Test Suite by grouping the test cases under one group
- Exporting Test Cases/Suites the supported language and save for Selenium RC to enhance them
- Finding reference of every API and Selense commands
- Debugging test cases by toggling breakpoints through the commands
- Almost all of the web pages are developed with AJAX technology since web2.0 evolution. While recording the page elements, Selenium IDE locates the page elements/objects using XPath/DOM/CSS. XPaths are found automatically, but you may have to update the specific elements in Xpath manually by looking into the source of the page to make them unique. Firebug is the helpful firefox Add-on for this purpose.
- Every command has maximum two arguments. The first is usually target element pointed by its ID, name, link, DOM, CSS or XPath and the second is the value to that target element if exists. The selenium IDE commands when saved in the programming language of our choice for selenium RC purpose are called as Selenese.
- The common commands are open, click, type, assert, verify. Commands beginning with ‘assert’ or ‘verify’ are for checks and verifications. If verify command is used and it fails, it fails the test case and continue to run the remaining tests. If assert command is used and it fails, the test case is aborted and stops to run the remaining tests.
- For synchronizing the flow of test execution Selenium has commands ending with ‘AndWait’, it tells Selenium to wait for the page to load after the action has been done. However, it fails when using AJAX calls. In this case you have to use ‘WaitFor’ commandsmand
No comments:
Post a Comment