You are on page 1of 4

Selenium

Introducing Selenium
Selenium is a robust set of tools that supports rapid development of test automation for web-based
applications. One of Selenium’s key features is the support for executing one’s tests on multiple browser
platforms.

Selenium Components
Selenium is composed of three major tools. Each one has a specific role in aiding the development of web
application test automation.

Selenium-IDE
Selenium-IDE is the Integrated Development Environment for building Selenium test cases. Selenium-
IDE has a recording feature, which will keep account of user actions as they are performed and store them
as a reusable script to play back.

Selenium-RC (Remote Control)


Selenium-RC allows the test automation developer to use a programming language for maximum
flexibility and extensibility in developing test logic. For instance, if the application under test returns a
result set, and if the automated test program needs to run tests on each element in the result set, the
programming language’s iteration support can be used to iterate through the result set, calling Selenium
commands to run tests on each item.

Selenium-Grid
Selenium-Grid allows the Selenium-RC solution to scale for large test suites or test suites that must be run
in multiple environments

Test Suites
A test suite is a collection of tests. Often one will run all the tests in a test suite as one continuous batch-
job. When using Selenium-IDE, test suites also can be defined using a simple HTML file. The syntax
again is simple. An HTML table defines a list of tests where each row defines the file system path to each
test.

Building Test Cases


There are three primary methods for developing test cases. Frequently, a test developer will require all
three techniques.

1. Recording
Many first-time users begin by recording a test case from their interactions with a website.
During recording, Selenium-IDE will automatically insert commands into your test case based on your
actions. Typically, this will include:
• clicking a link - click or clickAndWait commands
• entering values - type command
• selecting options from a drop-down listbox - select command
• clicking checkboxes or radio buttons - click command
2. Adding Verifications and Asserts With the Context Menu

Test cases will also need to check the properties of a web-page. This requires assert and verify
Commands. With Selenium-IDE recording, go to the browser displaying your test application and right
click anywhere on the page.

3. Editing

Insert Command
Table View
Select the point in your test case where you want to insert the command. To do this, in the Test Case
Pane, left-click on the line where you want to insert a new command. Right-click and select Insert
Command; the IDE will add a blank line just ahead of the line you selected. Now use the command
editing text fields to enter your new command and its parameters.
Source View
Select the point in your test case where you want to insert the command. To do this, in the Test Case
Pane, left-click between the commands where you want to insert a new command, and enter the HTML
tags needed to create a 3-column row containing the Command, first parameter (if one is required by the
Command), and second parameter (again, if one is required). Be sure to save your test before switching
back to Table view.

Running Test Cases


The IDE allows many options for running your test case. You can run a test case all at once, stop and start
it, run it one line at a time, run a single command you are currently developing, and you can do a batch
run of an entire test suite. Execution of test cases is very flexible in the IDE.
Run a Test Case Click the Run button to run the currently displayed test case.
Run a Test Suite Click the Run All button to run all the test cases in the currently loaded test suite.
Stop and Start The Pause button can be used to stop the test case while it is running. The icon of this
button then changes to indicate the Resume button. To continue click Resume.
Stop in the Middle You can set a breakpoint in the test case to cause it to stop on a particular command.
This is useful for debugging your test case. To set a breakpoint, select a command, right-click,
and from the context menu select Toggle Breakpoint.
Start from the Middle You can tell the IDE to begin running from a specific command in the middle of
the test case. This also is used for debugging. To set a startpoint, select a command, right-click, and from
the context menu select Set/Clear Start Point.
Run Any Single Command Double-click any single command to run it by itself. This is useful when
writing a single command. It lets you immediately test a command you are constructing, when you are not
sure if it is correct. You can double-click it to see if it runs correctly. This is also available from the
context menu.

Reporting Results
Selenium-RC does not have its own mechanism for reporting results. Rather, it allows you to build your
reporting customized to your needs using features of your chosen programming language
Test design Considerations
The whole reason for using Selenium-RC is to add programming logic to the tests.

Iteration
Iteration is one of the most common things people need to do in their tests. For example, you may want to
execute a search multiple times

Condition Statements
A common problem encountered while running Selenium tests occurs when an expected element is not
available on page Condition statements are used in solve this problem.

Conclusion

The advantages of using Selenium are

• Frequent regression testing


• Rapid feedback to developers during the development process
• Virtually unlimited iterations of test case execution
• Customized reporting of application defects
• Support for Agile and eXtreme development methodologies
• Disciplined documentation of test cases
• Finding defects missed by manual testing
kboxes or radio buttons - click command

You might also like