Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language (Selenium IDE).
Selenium
is at present the most powerful freeware of open source automation
tool. It is developed by Jason Huggins and his team. This is release
under the Apache 2.0 license and can be downloaded and used without any
charge. Selenium is easy to get started with for simple functional
testing of web application. It supports record and playback for testing
web based application. Selenium supports multithreading feature i.e.
multiple instance of script can be run on different browsers.
Advantages:
Selenium is pure open source, freeware and portable tool.
- Selenium supports variety of languages that include Java, Perl, Python, C#, Ruby, Groovy, Java Script, and VB Script. etc.
- Selenium supports many operating systems like Windows, Macintosh, Linux, Unix etc.
- Selenium supports many browsers like Internet explorer, Chrome, Firefox, Opera, Safari etc.
Selenium can be integrated with ANT or Maven kind of framework for source code compilation.
Selenium can be integrated with TestNG testing framework for testing our applications and generating reports. - Selenium can be integrated with Jenkins or Hudson for continuous integration.
Selenium can be integrated with other open source tools for supporting other features.
Selenium can be used for Android, IPhone, Blackberry etc. based application testing.
Selenium supports very less CPU and RAM consumption for script execution.
Selenium comes with different component to provide support to its parent which is Selenium IDE, Selenium Grid and Selenium Remote Control (RC).
Disadvantages:
- Selenium needs very much expertise resources. The resource should also be very well versed in framework architecture.
- Selenium only supports web based application and does not support windows based application.
It is difficult to test Image based application. - Selenium need outside support for report generation activity like dependence on TestNG or Jenkins.
Selenium does not support built in add-ins support. - Selenium user lacks online support for the problems they face.
- Selenium does not provide any built in IDE for script generation and it need other IDE like Eclipse for writing scripts.
- Selenium Automation Engineers are bit in scarcity these days.
- Selenium script creation time is bit high.
- Selenium does not support file upload facility.
- Selenium partially supports for Dialog boxes.
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.
- Quality 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):
In this mode only Selenium IDE
is used to record the test scenarios in terms of test cases in firefox.
This is a great way to get started to writing tests and group them
together to form the test suite. The recorded tests can be exported to
many programming languages so that we can tweak them and put them in the
testing framework. The test cases and test suites can be replayed back
to check the verifications and validations or sent to Selenium RC or
Grid for further tweaking.
- Selenium Remote Control (RC) Mode
In
this mode Selenium starts multiple browsers (one at a time) and then
runs the recorded test-cases which are saved in your language of choice.
This helps to enhance the test cases with looping and programming
techniques to cover all the required test scenarios and checks.
- Test Runner Mode
In
this mode the test cases are recorded ad replayed in the form of HTML
tables. This is just one more facility to execute the Selenium IDE as
well as RC test cases. This helps to check the test results reports in
better manner if not formatted already.
Testing AJAX with Selenium
Selenium IDE – Recording and updating a script
Selenium 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
Selenium IDE – Most commonly used commands
The following are the most commonly used commands in the Selenium IDE:
open: Opens a page using a URL.
click: Clicks the element/object on the page.
clickAndWait: Performs a click operation, and optionally waits for a new page to load.
verifyTitle: Verifies the expected title and continues to run if it fails.
assertTitle: Verifies an expected page title and stops the execution if it fails.
verifyTextPresent: Verifies that the expected text is present somewhere on the page.
verifyElementPresent: Verifies an expected UI element, as defined by its HTML tag.
verifyText: Verifies that the expected text and its corresponding HTML tag are present on the page.
waitForPageToLoad: Pauses execution until an expected new page loads.
waitForElementPresent:Pauses execution until an expected UI element, as defined by its HTML tag, is present on the page. Used with AJAX calls.