How to set up a Headless Selenium Testing environment for CentOS 6.3.
Follow these steps to set up a CentOS 6.3 host to run headless Selenium tests with Firefox.
sudo yum -y install firefox Xvfb libXfont Xorg
sudo yum -y groupinstall "X Window System" "Desktop" "Fonts" "General Purpose Desktop"
(installation takes a few minutes)- Launch an XWindows Virtual Frame Buffer(XVFB) session on display port 99:
Xvfb :99 -ac -screen 0 1280x1024x24 &
- Tell all XWindows applications in this terminal session to use the new Xvfb display port:
export DISPLAY=:99
- Start the Selenium server, eg:
java -jar /opt/selenium-server-standalone.jar &
- Now start your Selenium tests. The Selenium server should spawn a headless Firefox instance and your tests should run successfully.
How to install an XWindows terminal so that you can connect to your CentOS 6.3 host and run your Selenium tests in a graphical Web browser. This capability will be invaluable whenever you need to debug Selenium tests on one of your remote hosts.
- Open XQuartz and ssh to your CentOS host using the
-X
option, eg:ssh -X [email protected]
- On the remote host, type
export DISPLAY=localhost:10.0
- Start the Selenium server in the same terminal session, eg:
java -jar /opt/selenium-server-standalone.jar &
- Now simply run your tests and you will see Firefox start up and run in the GUI, just like on the destkop!
Note that it's much slower to execute the tests under XWindows vs. Xvfb.
- Open XQuartz and ssh to your CentOS host using the
-X
option, eg:ssh -X [email protected]
- On the remote host, type
export DISPLAY=localhost:10.0
- On the remote host, type
firefox &
and after a long pause you should see Firefox start up in a GUI window.
XQuartz replaces the old X11 terminal that was part of Mac OS up until Mountain Lion. If you have an older version of Mac OS X then X11 should already be installed, and you can mentally replace "XQuartz" with "X11" throughout these instructions.
- Get XQuartz here. http://xquartz.macosforge.org/landing/ (The download will take a few minutes.)
- Run the installer.
- Log out and log back in.
- That's it! XQuartz should now be installed.
Hi - I followed these instructions above, but ran into an issue with Firefox not working due to some library mismatches in RHEL 7.1. After trying several things to no avail, I uninstalled the default firefox package (yum delete firefox) and installed specifically the .i686 package (yum install firefox.i686). Which I know seems counterintuitive, since RHEL is running on the x86_64 architecture, but for some reason, this did it for me.
Just letting other people know this might work, since I spent a good few days dabbling "in the dark".