Contents

Introduction

As documented at Running_Automated_Tests_for_Version_1.6, Joomla! 1.6 now includes a library of system tests. This document details the steps necessary to create system tests using Selenium IDE. You will also need to run Firefox and install the Selenium IDE add-on to Firefox. Instructions for this can be found in the System Testing article.

NOTE: This article assumes that you have read the aforementioned articles and have PHPUnit and Selenium set up and working properly.

Overview

Writing a system test essentially entails converting a Selenium IDE test to a format that we can easily integrate into the Joomla! test suite. See System Testing for a good primer on system tests.

Tips & Tricks

It is recommended to update your local copy of Joomla! to the latest build before writing or using any tests.

Some of the tests written for Joomla! version 1.6 use the included sample data. You need to install the sample data to run these tests.

System tests are loosely dependent on the default templates. The systems tests written for version 1.6 use the rhuk_milkyway (front end) and bluestork (back end) templates.

It is recommended that tests "undo" any changes made to the site. This can be done as part of the test. Other tests may encounter issues if artifacts of other tests are present.

The test are written in PHP and we are using Selenium RC to execute them later. You will need to select the PHP Selenium RC Format in Selenium IDE. Go to Options -> Format -> PHP Selenium RC

require_once 'SeleniumJoomlaTestCase.php';? allows use to utilize the methods that belong to the Selenium Joomla Test Case class

class ControlPanelExample extends SeleniumJoomlaTestCase extends a class into our SeleniumJoomlaTestCase to implement the client/server protocol to talk to Selenium RC as well as specialized assertion methods for web testing.

2. Open Selenium IDE by going to the Tools menu and select Selenium IDE. Selenium will start recording automatically and the red record button will appear highlighted (see image below).

3. Verify that the Base URL displayed in Selenium, next to the record button, is that of your test site.

4. Perform the test by following the instructions described above (Note: there are some slight variations between the test described above and the one we performed. This is due to variation of 1.6 during the development process).

5. When you have completed your test, click the the red record button (see image below) to stop recording.

6. Once recording has stopped, create a new PHP file in Eclipse (or your favorite code editor) and copy / paste the code from Selenium IDE to there. The contents of the example test is:

1. The first step in integrating this test into tests/suite is to call SeleniumJoomlaTestCase.php so that we can utilize the Selenium Test Case Methods. To do this, we will replace the first portion of our code:

<?php
require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

with the following code

<?php
require_once 'SeleniumJoomlaTestCase.php';

We can now start utilizing the Selenium Joomla Test Case Methods.

2. We will now extend a class into our SeleniumJoomlaTestCase to implement the client/server protocol to talk to Selenium RC as well as specialized assertion methods for web testing.

At this point, running the test would successfully launch a two browsers instances, one for Selenium Remote Control and one for test itself, but it would fail due to the lack of the password being recorded. Additionally, we want to be sure that none of the path information is hard coded in the test.

3. To improve our code, and achieve what we noted above, we would delete the function below: