TestingSelenium » History » Revision 16
« Previous |
Revision 16/37
(diff)
| Next »
Andreas Kohlbecker, 03/15/2011 02:17 PM
Functional Website Testing with Selenium¶
We will use Jenkins CI":http://jenkins-ci.org/ in order to run "SeleniumHQ tests headlessly on a Debian server.
Install SeleniumHQ¶
The Selenium Server is needed in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones. Download the Selenium Standalone Server from http://code.google.com/p/selenium/ into an appropriate location and create a softlink:
mkdir /opt/seleniumhq cd /opt/seleniumhq wget http://selenium.googlecode.com/files/selenium-server-standalone-${Version}.jar ln -s selenium-server-standalone-${Version}.jar selenium-server.jar
Test run the selenium server
edit-develop:/opt/seleniumhq# java -jar selenium-server.jar 15-Mar-2011 12:29:48 java.util.prefs.FileSystemPreferences$2 run INFO: Created user preferences directory. 12:29:48.291 INFO - Java: Sun Microsystems Inc. 17.1-b03 12:29:48.295 INFO - OS: Linux 2.6.26-1-xen-amd64 amd64 12:29:48.299 INFO - v2.0 [b2], with Core v2.0 [b2] 12:29:48.475 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub 12:29:48.479 INFO - Version Jetty/5.1.x 12:29:48.479 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] 12:29:48.479 INFO - Started HttpContext[/selenium-server,/selenium-server] 12:29:48.479 INFO - Started HttpContext[/,/] 12:29:48.507 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@68e6ff0d 12:29:48.507 INFO - Started HttpContext[/wd,/wd] 12:29:48.511 INFO - Started SocketListener on 0.0.0.0:4444 12:29:48.511 INFO - Started org.openqa.jetty.jetty.Server@30f7f540
See http://www.danstraw.com/installing-selenium-server-2-as-a-service-on-ubuntu/2010/09/23/ for how to start selenium as service.
Install xvfb¶
The following installation instructions have been copied from the great guidance on this topic http://www.danstraw.com/running-selenium-tests-on-debian-headlessly-using-iceweasel-and-firefox/2010/11/24/, though we found that we need to install additional packages we decided repeat and extend this guidance here.
To install xvfb:
sudo apt-get install xvfb apt-get libgl1-mesa-dri xfonts-cyrillic xfonts-100dpi xfonts-75dpi
And then to check everything’s OK:
Xvfb :99
Where :99 is the display number. We set it to 99 to avoid any conflict with other displays, should they be attached. The command line should just hang without any comments until you press CTRL-C to close.
Install iceweasel (firefox)¶
To install iceweasel, which is currently the debian version of firefox:
sudo apt-get install iceweasel
And then, once you’re installed, to test that it works OK.
Start Xvfb in one window as above,
then in a second terminal window:
export DISPLAY=:99 firefox
you should see nothing except maybe a message that the extension [RANDR" missing on display ](99.0"
) – firefox should just sit there until you CTRL+C.
The “export DISPLAY=:99″ line is telling firefox to use display # 99, which we started above.
we want to take take a screenshot in order to check that everything is ok. We will use ImagMagick to take screen shots in addition we also install the x11-utils in order get the xwininfo
tool.
See also:
apt-get install imagemagick x11-utils
Now take a screenshot of the root
window:
export DISPLAY=:99 import -window root example.png
The screenshot would look like this:
[!examplepng|50%!]
If you want to get a list of all windows currently managed by Xvfb :
xwininfo -root -tree
Create the headlessSelenium start up script¶
Jenkins CI¶
Install the Seleniumhq Plugin.
Updated by Andreas Kohlbecker about 13 years ago · 16 revisions