Web testing with Selenium
For the Selenium server to run you will need Java installed and the PATH environment variable correctly configured to run it from the console. You can check that you have Java correctly installed by running the following command on a console:java -version
If you get a version number (which needs to be 1.5 or later), you are ready to start using Selenium-RC
If you don't have Java installed or its version is lower than 1.5 you need to download Java:
Selenium Remote Control (RC)
Selenium RC comes in two parts:
- A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them.
- Client libraries for a number of computer languages.
Downloading the Selenium-RC
After downloading and unzipping the Selenium-RC zip file, you will see a folder selenium-remote-control-<version> containing the following sub-directories:
These folders have all the components you need for using Selenium-RC with the programming language of your choice.
Now you simply need to:
- Install the Selenium-RC Server.
- Set up a language specific client driver (in this particular case Perl client driver).
Installing Selenium Server
The Selenium-RC server is simply a Java jar file, which doesn't require any special installation. Just extracting the server in the desired directory is sufficient.
After unzipping of Selenium-RC zip file the path to the Java jar file should be: selenium-remote-control-<version>/selenium-server-<version>/selenium-server.jar
Set up Perl client driver
The driver which you need to install is selenium-perl-client-driver-<version>.
The path to the Makefile.PL file should be: selenium-remote-control-<version>/selenium-perl-client-driver-<version>/Makefile.PL
In order to install the driver go to the directory where the Makefile.PL is located and run it (from a command-line console) as shown below:perl Makefile.PL
Once the perl driver is install, you can start the selenium server.
The Test Scripts
Check-out the test scripts from CVS:
$ mkdir selenium_tests $ cvs co -d selenium_tests eg-plugins/testsuite/selenium_Location.pl $ cvs co -d selenium_tests eg-plugins/testsuite/selenium_Gene.pl $ cvs co -d selenium_tests eg-plugins/testsuite/selenium_Transcript.pl
The script selenium_Location.pl is meant to test for broken or non-existent links in the Location section of Human genome page in Ensembl website.
Respectively, the script selenium_Gene.pl is meant to test for broken or non-existent links in the Gene section and the script selenium_Transcript.pl is for testing of the Transcript section of Human genome page in Ensembl website.
Running Selenium Server
Before starting any tests you must start the server. Go to the directory where Selenium-RC’s server is located and run the following from a command-line console.java -jar selenium-server.jar
This can be simplified by creating a batch or shell executable file (.sh on Linux) containing the command above.
After the successful starting of the server the tests are ready to be run.
Running Test Scripts
Each of the scripts can accept two (optional) parameters:
- url - the URL address of the website which is supposed to undergo testing. By default the URL address is set to http://www.ensembl.org
- skip - a list of links (comma separated) which will be skipped during the test. By default all available links from the left vertical menu of the current web page undergo testing.
Running a test script with passed parameters
$ perl selenium_Gene.pl --url="http://www.ensembl.org" --skip="External Data, Gene history"
Remark: The launching of the browser normally takes a couple of seconds.