CI | java jenkins python Thu 06 September 2012 Olivier Mansion

In Selenium tests with Django 1.4+ we saw how to run Selenium tests on Django 1.4+ based projects.

However, these tests were run on a single Web Driver, ie. a single browser.

Fortunately, Selenose 1.3 makes it easy to test on multiple browser. Let's switch the single browser tested project to a multiple browser tested project.

Sample project

Let's use the same poll application from the Django tutorial.

The source code can be found on the django14-selenose branch of this repository. Clone it with:

$ git clone -b django14-selenose

Then step in the new djangotutorial-selenium folder, and install all requirements with pip by typing:

$ pip install -r requirements.txt

Configure tests

We should be able to switch browser via an option on the jenkins command line. To do so, edit djangotutorial/ and set JENKINS_TASKS:


The first tasks are the django-jenkins default ones, but note the last one: selenose.tasks.selenium_driver. This is the core of the solution.

Write tests

In our project, Selenium tests are located in the polls/ module.

Make all you tests inherit from selenose.cases.LiveServerTestCase. A test template would be:

from selenose.cases import LiveServerTestCase

class SampleTestCase(LiveServerTestCase):

    def test(self):
        # You scenario here

Run tests

Then to run tests on Firefox, just execute:

$ python jenkins --selenium-driver=firefox
Creating test database for alias 'default'...
Ran 2 tests in 15.258s

Destroying test database for alias 'default'...

On Chrome? easily done (requires the Chrome Driver):

$ python jenkins --selenium-driver=chrome

This section details all the capabilities.

Need a Selenium Server?

Edit djangotutorial/ and append selenose.tasks.selenium_server to JENKINS_TASKS:

    # Other tasks


For a full documentation, see the Django Jenkins section on

What's next?

In the next blog post, we will see how to integrate this project with Jenkins!

Boost Your Teams