Thursday, November 20, 2008

Selenium Test Suite

Selenium Test Suite

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 (http://selenium-core.openqa.org/) 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>Sample Test Suite</title>

</head>

<body>

<table>

<tr>

<td><b>Suite</b></td>

</tr>

<tr>

<td><a href="./Script1.html" mce_href="./Script1.html">Script 1 </a></td>

</tr>

<tr>

<td><a href="./Script2.html" mce_href="./Script2.html">Script 2</a></td>

</tr>

<tr>

<td><a href="./Script3.html" mce_href="./Script3.html">Script 3</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.

No comments: