In previous article (http://ygerasimov.com/integrating-selenium-to-drupal-simpletest-framework) I have written about introducing Selenium tests to Drupal simpletest framework.
The first question I got on IRC from Randy Fay was whether we can run selenium tests from console. Today I have managed to do that and I would like to share how to set environment.
So demo first!
I have installed clean Debian to my VirtualBox. Installed lamp stack and java environment. Cloned and installed http://drupal.org/sandbox/ygerasimov/1131210 project with module from http://drupal.org/sandbox/ygerasimov/1131220.
The main trick to run tests headless is Xvfb tool (http://en.wikipedia.org/wiki/Xvfb) to emulate X windows and run applications from console. Installation of this tool is quite easy (sudo apt-get install xvfb).
Then before we start our selenium server we need to start xvfb:
Xvfb :99 -ac & export DISPLAY=:99
Some nice instructions can be found here http://www.alittlemadness.com/2008/03/05/running-selenium-headless/
If you would like to test your xvfb running with capturing screenshot with "import -window ..." please remember to install imagemagick tools (sudo apt-get install imagemagick).
Then we can start our Selenium server and run our tests.
To run tests from Selenium Test Example module we should run:
sudo -u www-data php ./scripts/run-tests.sh --url http://192.168.1.15/selenium --class SeleniumTestExample
I believe Selenium is really great tool that we can use in our daily development and now we can even run it on server. I hope it would be possible to integrate this testing to testing infrastructure of the d.o.
Lets see how it goes! Happy testing!