I have been asked to create a web site performance test (not: load test), i.e. measure the duration of a specific clickstream in a controlled (no-load) environment.
This is how I got to a proof concept using Selenium and phpunit under Ubuntu 08.04.
- Install the packages:
php5
php5-pear
- Install phpunit and SeleniumRC:
Download and untargz: http://selenium-rc.openqa.org/download.html
Install PEAR module for accessing SeleniumRC:
sudo pear install channel://pear.php.net/Testing_Selenium-0.4.3
Install phpunit with PEAR:
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit
- Create the test and place measurements:
Record in SeleniumIDE and export as PHP. Insert something like:
$start = microtime(true);
// Test 1 here
$end = microtime(true);
echo ($end-$start) . ",";
$start = microtime(true);
// Test 2 here
$end = microtime(true);
echo ($end-$start) . ",\n";
- Configure the browser in your exported tests:
At the time of this writing, Firefox 3 is not working out of the box with the PlugIns that SeleniumRC provides and requires. I installed Firefox 2 in parallel and changed the generated line
$this->setBrowser("*chrome");
to
$this->setBrowser("*firefox /usr/lib/firefox/firefox-2-bin");
in mytest.php
- Launch SeleniumRC:
java -jar selenium-server.jar
Edit: If you're testing an SSL server, adding the -avoidProxy option might save some trouble.
- Run your test:
phpunit yourtest.php
The output would be single line of CSV. Of course this approach doesn't scale at all, and the implementation of Selanese
waitFor-commands needs to be modified.
If you know of a more standardized way to record and analyze measurements, let me know. If there is nothing, this might be a nice enhancement for the SeleniumIDE export function.
Last edit: Changed phpunit-installation from package to PEAR