Jabberwocky

snicker-snack!

Selenium

| Comments

Selenium is a tool for integration testing – you run tests directly in your browser – the browser of your choice – and test the whole stack, from client javascript to database access.

Cucumber can integrate with selenium. It’s one of the ways to factor in javascript in your tests.

Installing

Installing Selenium itself is a piece of cake. Download Selenium Core from here. Unzip the archive, and copy the content of the core directory into a publically accessible directory on the same location (virtualhost/server) as your application. In rails, this means in a subdirectory of public.

IDE

In our project, we plan to use Selenium for User Acceptance testing. The testers don’t want to redo every test scenario. Selenium IDE is the answer: before you start to run a scenario you start recording, and you stop after you’re done.

Selenium IDE is a Firefox extension. Download it from the same location. Load it using File –> Open File.

Integrating selenium tests in test sets

Selenium IDE allows you to export to Ruby, .Net, Java. They might need to be edited a little – the generated class for test cases for instance, or the configuration under which to run to run the tests (url, browser).

To run those tests an extra tool is needed: Selenium Remote Control, and corresponding driver for your language. Download Selenium RC from the same site again. The only component you’re going to use is selenium-server.jar (Under Debian, you might need to install the packages sun-java6-jdk update-java-alternatives -s java-6-sun)

1
java -jar selenium-server.jar

Which starts jetty, a light java server, by default on port 4444

In Ruby

1
gem install selenium-client

Then you can run your tests, as you would normally, maybe with their own rake task.

Selenium does Firefox, IE, Safari – not yet Chrome for as far as I know. These have to be installed on the machines you run the test on.

It might make more sense to run these tests as part of continuous integration, as they are known to be slower. But it’s really handy to have them, as they do reflect the users’ experience.

Comments