In our first post on Selenium in Python, we saw how to prepare your continuous integration environment on Debian. In the second one, we saw how to enable Selenium tests in your existing web project. Now it's time to see how to integrate all this within Jenkins!
First ensure that the latest version of the ShiningPanda Plugin and Xvnc Plugin are installed (check on Manage Jenkins > Manage Plugins > Installed page). If not, look for them in the Available tab and perform the installation (don't forget to restart Jenkins).
Then declare all the Python installations you want to test on with the Manage Jenkins > Configure System page (one shot configuration):
To add an installation, search the Python section and click on Add Python. Then give the installation a name and enter its home folder (ie. PYTHONHOME).
This tutorial is based on the sample described in our last post. Our goal is to test the project on several different web browsers, or in this context: Web Driver environments.
First of all, create a New Job, enter its name (here djangotutorial) and select Build multi-configuration project before validating.
As usual, setup:
Axis provide parameters to the build. At least two axis are required for this project:
To create a Web Driver axis, click on Add axis in Configuration Matrix section and select User-defined axis.
For more informations on Web Driver environments, see selenose documentation.
Click once more on Add axis and select Python to be able to select the Python interpreter running the web server.
In this example, only Python 2.7 is tested but feel free to add additional interpreters.
A display is required to run Selenium tests.
To start one, enable Run Xvnc during build in the Build Environment section.
To be able to install all required package, a Virtualenv Builder is recommended.
Click on Add build step in Build section and select Virtualenv Builder.
In the Command field enter all required steps:
Add all the desired post-build actions. Here Jenkins is asked to parse the XML test and coverage reports and to send mails on failure.
Finally start a new build by clicking on Build Now: execution results by Web Driver environment are directly available on the main page of the project.
Testing on multiple Web Driver environments can be time and resource consuming.
To ensure that a revision is worthwhile to test on all environments, you can execute a touchstone build first:
To enable this option, look for a Execute a touchstone build first checkbox in the Configuration Matrix and check it.
The syntax for filter is WEBDRIVER=="<environment>", where <environment> is the name of the Web Driver environment you want to test on first.
Here the touchstone build is executed with Firefox (WEBDRIVER=="firefox") but it could also have been Chrome (WEBDRIVER=="chrome").