RUNNING SELENIUM TESTS
This section describes setting up and running Selenium Perl tests on the command line. There are 3 steps to making this work:
- 1. Start your web application
- 2. Start the Selenium server
- 3. Run your Perl tests
Each of these components may or may not run on the same computer depending on how you want to set it up. The only tricky part is configuring the right servers and ports so all 3 components talk to each other. This is done either with the options you pass to Test::WWW::Selenium::More->new() (see WWW::Selenium) or with the environment variables described in Test::WWW::Selenium::More.
These examples assume the web application you want to test is running on localhost, port 5000.
# Start the Selenium server java -jar selenium-server.jar -port 4444 -trustAllSSLCertificates -browserSessionReuse # Run your tests against your web app running on localhost, port 80 prove -lrv t/test.t
Headless server setup
# Start Xvfb so you can run a web browser without X Windows Xvfb :99 # Start the Selenium server DISPLAY=:99 java -jar selenium-server.jar -port 4444 -trustAllSSLCertificates -browserSessionReuse # Run your tests prove -lrv t/test.t
Run Selenium tests against a remote website
SELENIUM_BROWSER_URL=http://example.com prove -lrv t/test.t
Run tests against a remote Selenium server
# Start the Selenium server on the remote host (lets say 220.127.116.11). # Then run your tests locally like this: SELENIUM_HOST=18.104.22.168 prove -lrv t/test.t
Running tests slowly
# Tests fly by too fast sometimes when you are watching them in the # browser. This slows things down. It basically calls sleep after every # call to the Selenium server SELENIUM_SLEEP=1 prove -lrv t/test.t
The ENVIRONMENT VARIABLES section of l<Test::WWW::Selenium::More> documentation.
The command line options for the Selenium server
java -jar selenium-server.jar -h
Eric Johnson <kablamo at iijo dot nospamthanks dot org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Eric Johnson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.