Fencing Selenium With Xephyr
Earlier in the year I put Selenium in a cage using Xnest. This allows me to run browser-popping tests in the background without disturbing my desktop or (crucially) stealing my focus.
On that post Rohan stopped by to mention a nice alternative to Xnest: Xephyr. As the Xephyr homepage will tell you:
Xephyr is a kdrive based X Server which targets a window on a host X Server as its framebuffer. Unlike Xnest it supports modern X extensions ( even if host server doesn’t ) such as Composite, Damage, randr etc (no GLX support now). It uses SHM Images and shadow framebuffer updates to provide good performance. It also has a visual debugging mode for observing screen updates.
It sounded sweet, but I hadn’t tried it out until recently, on a newer box where I didn’t already have Xnest setup. The good news is the setup is as simple as with Xnest in my prior post:
- Install Xephyr: which runs an X server inside a window:
$ sudo apt-get install xserver-xephyr
- Install a simple window manager: again, for old times’ sake, I’ve gone for fvwm:
$ sudo apt-get install fvwm
- Start Xephyr: choose an unused display number (most standard setups will already be using 0) — I chose 1. As with Xnest, the -ac flag turns off access control, which you might want to be more careful about. My choice of window size is largely arbitrary:
$ Xephyr :1 -screen 1024×768 -ac &
- Set DISPLAY: so that subsequent X programs connect to Xephyr, you need to set the environment variable DISPLAY to whatever you passed as the first argument to Xephyr above:
$ export DISPLAY=:1
- Start your window manager: to manage windows in your nested X instance:
$ fvwm &
- Run your tests: however you normally would:
$ ant accept.master
Then just sit back and watch the browsers launched by Selenium trapped in the Xephyr window. Let’s see them take your focus now!
This entry was posted on Tuesday, December 1st, 2009 at 12:31 am and is filed under Agile, Build, Continuous Integration, Project Automation, Technology, Testing. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
