What are the equivalent directions for Ubuntu?

On your CentOS 6.3 host

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.


I ask because I use Gradle, so this is in the context of making a Gradle task, or, without using jar, just the default gradle run task with xvfb.

Preferably, how do I run the gradle run task through xvfb?

Current usage:

thufir@mordor:~/NetBeansProjects/selenium$ gradle run
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE

1 Answer 1


You likely don't want to run a gradle task through Xvfb, but rather execute something within an X Windows Virtual Frame Buffer FROM a gradle task.

For example your gradle test task might do:

xvfb-run -a --server-args='-screen 0, 1024x768x24' google-chrome -start-maximized http://runMyLocalBrowserBasedTest > /dev/null & 
  • this is a standard approach to headless selenium on linux/ubuntu?
    – Thufir
    May 17, 2016 at 1:36
  • this just hangs for me with variants on xvfb-run --auto-servernum --server-num=1 --server-args='-screen 0, 1024x768x24' firefox -start-maximized http://www.google.com > google.html or > /dev/null with or without the ampersand.
    – Thufir
    Jul 17, 2017 at 1:40
  • It likely IS producing an error that you just don’t see because it is going to /dev/null. Remove that and see what your problem is.
    – TomSchober
    Dec 6, 2017 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .