Jul 02
Creating a Selenium test suite
Posted by James Netherton | Monday 02 July 2007 0:07 AM | In Testing
Most testing frameworks have the concept of grouping a set of text fixtures into a ’suite’ so that you can execute a number of related tests together.
Creating test suites with Selenium doesn’t appear to be obvious at first. Here’s a simple guide on how to create and execute suites of functional tests:
You can run test suites via the Selenium web browser application. You’ll need to download the Selenium Core in order to do this. After you have extracted the downloaded file, copy the ‘core’ directory to somewhere that is accessible under your server web root (E.g the document root). Browse to http://your server/path to selenium core/TestRunner.html and you should see the Selenium test runner application.
In order to create a test suite, all you have to do is create an HTML document that is composed of a table of links to your individual unit tests. For example:
<html> <head> <title>My Application Test Suite</title> </head> <body> <table> <tr><td><b>Suite Of Tests</b></td></tr> <tr><td><a href="./TestLogin.html">Test Login</a></td></tr> <tr><td><a href="./TestFormEntry.html">Test Form Entry</a></td></tr> <tr><td><a href="./TestFormSave.html">Test Form Save</a></td></tr> </table> </body> </html>
Obviously you’ll need to adjust the href’s to wherever you have your test cases stored, but essentially that is all there is to creating a test suite.
Now return to the Selenium test runner application and alter the unit test path so that it finds the HTML file containing your test suite definition. When the page reloads you should see all of your individual unit tests listed within the frame on the left hand side. You now have the option of executing all tests within the suite or run selected tests.
The test runner reports results in the usual manner, stating the number of passes, failures or number of cases where errors were encountered within the actual test scripts.
All of this is quite handy because as I mentioned in my previous post, you could run a suite of tests as part of a continuous integration process upon application deployment or commits to a code repository.
6 Comments
[Post comment]
1
Posted by roger pack | Tuesday 02 October 11:10 AM
With Ruby on Rails the integrated plugin for selenium will generate the index for you
2
Posted by Madhavi | Tuesday 22 January 9:01 AM
hi,
Do you know any way to inbed one test suite into another. I need to create smaller test suites for each functionality and include those test suites into the master test suite.
Please let me know if you know any way out.
Regards,
Madhavi
3
Posted by Lindsay | Monday 05 May 0:05 AM
Hi, do you know of any way to run all cases in a test suite in a batch, ie. not having to run each individually?
cheers,
Lindsay
4
Posted by Chetan | Monday 11 May 11:51 AM
Hello,
I have read this document and its a nicely derived but can we do the same thing with perl??
Thanks
Chetan!
5
Posted by Mustafa | Thursday 25 June 9:13 AM
Hello,
Im new on selenium, I was wondering for which web browsers is it used.
6
Posted by James Netherton | Thursday 25 June 12:14 PM
Hi,
For a list of supported browsers, check out this FAQ page:
http://seleniumhq.org/about/platforms.html#browsers