Selenium (V)
Directory structure
_$: pwd
/home/jenkins/tests
_$: tree
.
├── firefox
│ ├── firefox
│ │ ├── ...
│ │ ├── firefox
│ │ ├── firefox-bin
│ └── firefox-24.6.0esr.tar.bz2
├── requirements.txt
├── selenium
│ ├── nosetest.xml
│ ├── test_admin.py
│ └── test_admin.pyc
├── selenium-server-standalone-2.42.2.jar
├── unit
│ ├── nosetest.xml
│ ├── tests.py
│ └── tests.pyc
└── venv
├── ...
Installation
1) Desktop environment
a) Debian
_$: aptitude install xorg xfce4
_$: aptitude install Xvfb
b) Ubuntu
_$: apt-get install xvfb
2) Firefox
Download Firefox (ESR) and move it to /home/jenkins/tests/firefox/
_$: wget https://download.mozilla.org/?product=firefox-24.6.0esr-SSL&os=linux64&lang=en-US -O firefox-24.6.0esr.tar.bz2
_$: mv firefox-24.6.0esr.tar.bz2 /home/jenkins/tests/firefox
_$: cd /home/jenkins/tests/firefox
_$: tar xvfj firefox-24.6.0esr.tar.bz2
_$: apt-get install libxrender1 libasound2 libgtkglextmm-x11-1.2-0 libgtk2.0-0
3) Standalone server
If we are to use Selenium Webdriver Remote we need the Selenium server.
_$: wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
Desktop environment configuration
a) Classic
root@selenium_$: Xvfb :99 -ac
selenium@selenium_$: export DISPLAY=:99
b) Modern
selenium@selenium_$: export DISPLAY=:99
selenium@selenium_$: cd /home/selenium/firefox/firefox
selenium@selenium_$: xvfb-run ./firefox
Virtual environment configuration
root@selenium_$: aptitude install python-pip
root@selenium_$: pip install virtualenv
selenium@selenium_$: mkdir selenium
selenium@selenium_$: cd ./selenium
selenium@selenium_$: virtualenv venv
selenium@selenium_$: cd venv
selenium@selenium_$: source bin/activate
(venv)selenium@selenium_$: pip install selenium
(venv)selenium@selenium_$: python projectcom-test
As a script
#!/bin/bash -
Xvfb :99 -ac
export DISPLAY=:99
PYTHON_PATH="/home/selenium/venv/bin/python"
/bin/bash /home/selenium/venv/bin/activate && \
$PYTHON_PATH /home/selenium/projectcom-test