Friday, 5 December 2008

Selenium, give me back my desktop!

Selenium is a great tool for testing web applications but, when running it locally, it does tend to take over your desktop with Firefox windows popping up constantly, leaving you twiddling your thumbs until the test suite is finished.

A beautifully lightweight and simple solution on Linux is to display the Firefox windows under test in an Xnest window.

So, here's my Selenium server startup script:


# Configure the display we'll run Xnest on and the location of the Firefox
# binary.
XNEST_DISPLAY=:10
FIREFOX_BIN="/usr/lib/firefox-3.0.4/firefox"

# Start Xnest and capture its pid.
Xnest $XNEST_DISPLAY -ac &
xnest_pid=$!

# From now on we want all X11 apps to start on Xnest's display.
DISPLAY=$XNEST_DISPLAY

# Let's run a nice, simple window manager on it.
openbox-session &

# Run the selenium server.
java -jar selenium-server.jar -forcedBrowserMode "*firefox3 $FIREFOX_BIN"

# Close the Xnest session.
kill $xnest_pid

No comments: