CDash:Testing/Selenium

Selenium is a testing tool for web applications. It reads in a script and uses it to drive a web browser. This allows us to test functionality in CDash (such as javascript) that we can't test with PHP alone.

Contents

Download Software

Selenium is based on java. If you don't already have java installed, download it here: Java downloads.

The Selenium tests in CDash uses PHPUnit under the hood. Download phpunit from their homepage or your favorite package manager.

On Windows, with xampp, you have to specify "phpunit.bat" explicitly to get it to work with a ctest-driven CDash dashboard:

cmake -DPHPUNIT_EXE:FILEPATH=C:/xampp/php/phpunit.bat ...

Running with XAMPP

go to xampp/php and then run the following

./pear.bat channel-discover pear.phpunit.de

./pear.bat install --alldeps --force phpunit/PHPUnit

./pear.bat install phpunit/PHPUnit_Selenium

Run the Selenium Remote Control Server

All of the Selenium-based tests in CDash will fail if the Selenium RC server isn't running. Fortunately, this is pretty easy to do:

:# On Windows, you may have to add the browser to the PATH before starting selenium:
set PATH=C:\Program Files (x86)\Mozilla Firefox;%PATH%
cd /path/to/selenium/selenium-server-1.0.3
java -jar selenium-server.jar

See CDash:Testing/Nightly for information about automatically starting & stopping the Selenium server from a nightly build.

Write New Tests

If you'd like to write new Selenium-based tests for CDash, you'll need to download the Selenium IDE from SeleniumHQ. This is a plugin for the Firefox web browser. Writing new tests is generally pretty easy.

In Firefox, select Tools -> Selenium IDE

This will automatically create a new test case and start recording. Just interact with your web browser as you normally would to record the behavior that you'd like to test.

When you're done, click the red circular record button to stop the test.

Select File -> Export test case -> PHP. You should also save the test as .html in case you need to edit it at a later date.

You'll have to edit the resulting .php file to remove hardcoded paths and host names. Take a look at the other .php files in CDash/testing/selenium for an example of how to do this.