Thursday, July 15, 2010

Selenium RC headless on linux

My laptop is slow enough with only 1.2G RAM and I don't want to make it even slower by running the Selenium server and an instance of Firefox (I used Chrome all the time). Better make use of the idle dev server at the office. So I'm thinking of running the Selenium server at the remote machine and use ssh tunnel to proxy port 4444 on my laptop to port 4444 on remote server. When running the test, the server gave an error message "Failed to start new browser session ...". Already expecting this since X is not running on the remote server.

Googling around, the solution is simple. Our old friend X frame buffer to the rescue. So just apt-get install xvfb and use the following command:-

$ Xvfb :1&
$ export DISPLAY=:1

and then restart the Selenium server. You can see the test running now through the console (of course you can't see the real browser opening up). For some reason, Xvfb doesn't return my prompt so I have to explicitly put it to the background with '&'.

1 comment:

Foobaz said...

thanks, works like charm

$ Xvfb :1&
$ DISPLAY=1 java -jar selenium-server.jar