Skip to content

Instantly share code, notes, and snippets.

@gabrielhurley
Created July 2, 2012 19:43
Show Gist options
  • Save gabrielhurley/3035227 to your computer and use it in GitHub Desktop.
Save gabrielhurley/3035227 to your computer and use it in GitHub Desktop.
Jenkins Selenium Setup

Selenium Jenkins Integration

Medium detail overview of steps involved

  • Add appropriate packages to build slave:

    sudo apt-get install xvfb          # virtual display
    sudo apt-get install x11-apps      # installs xwd (for taking screenshots)
    sudo apt-get install imagemagick   # for converting screenshots
    sudo apt-get install firefox
    
  • Create xvfb launch script:

    #!/bin/bash
    
    if [ -z "$1" ]; then
        echo "`basename $0` {start|stop}"
        exit
    fi
    
    case "$1" in
        start) /usr/bin/Xvfb :5 -ac -screen 0 1024x768x8 &;;
        stop) killall Xvfb;;
    esac
    
  • Set xvfb script to launch at startup:

    sudo update-rc.d xvfb defaults 10
    
  • Install Selenium server on build slave:

    wget http://selenium.googlecode.com/files/selenium-server-standalone-2.0b2.jar
    sudo mkdir /var/lib/selenium
    sudo mv selenium-server-standalone-2.0b2.jar /var/lib/selenium
    cd /var/lib/selenium
    sudo ln -s selenium-server-standalone-2.0b2.jar selenium-server.jar
    
  • Add Jenkins plugin (only if using Selenium directly rather than through Django test suite):

  • Configure "Exceute shell" job:

    export DISPLAY=":5" && java -jar /path/to/selenium-server.jar -browserSessionReuse -htmlSuite *firefox "http://path/to/app" "/path/to/tests/suite.html" "/path/to/results/results.html"
    
        OR (since we have Django + Selenium integration)
    
    ./run_tests.sh --with-selenium
    
  • Configure post-build reporting in plugin:

    • Depends on plugin...
  • Run a build!

Questions

  1. Better to use the Django/Selenium integration as we have it now or generate a selenium test suite to be driven directly by Selenium + Jenkins?
  2. Which plugin to use (if driving with Selenium directly).

Other useful info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment