Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install headless Firefox on CentOS 6 for Selenium automation


In the manual the steps required to install headless Firefox on CentOS 6 are described. Headless Firefox may be needed to perform GUI automated testing.

All steps of this manual have been validated on CentOS 6.8. It should not be a problem to adapt the solution to other distros.


Upgrade yum

yum upgrade

Install firefox from the official distro

Note: it may not be the latest version.

yum install -y firefox 

Install flash plugin

Your Firefox installation probably needs Adobe Flash plugin to render flash objects.

Install Adobe repo

yum -y install

The flash plugin itself

yum install flash-plugin

Install X server and Co.

yum groupinstall "X Window System" "Desktop" "Fonts"

Install the required extensions on Firefox

Assuming you're working from Linux, use your terminal to get into your remote host with X tunneling enabled issuing

ssh -X root@host

Being inside the remote host, issue


to run host's Firefox on your desktop.

You probably need to wait several seconds (or minutes, depending on your connection speed) to get host's Firefox to be running on your machine.

Install all needed extensions, e.g. Adblock Plus.

Install ImageMagick

You have only two ways to get the feedback from your headless Firefox: (1) take a screenshot from the virtual display it runs on or (2) get Firefox's console logs to some server you arranged for that. To take screenshot you need ImageMagick utility.

yum install -y ImageMagick

Install Xvfb

This is virtual display driver that allows Firefox to send its GUI output to virtual display.

yum install -y Xvfb

Run Xvfb to create virtual display on which headless Firefox will run

Xvfb :19 -screen 0 1024x768x16 &

Run Firefox on the virtual display

DISPLAY=:19 firefox "" 

This will force Firefox to run on virtual display 19 created by Xvfb.

Take screenshot of the virtual display on which Firefox runs

DISPLAY=:19 import -window root screenshot.png

Install and configire consoleexport

You may absolutely want to install consoleexport extension to be able to send Firefox's console logs to some remote server. There is no other convineint way to get console logs from headless Firefox.

consoleexport is firebug's friend therefore you install first firebug and then consoleexport:

  1. Install firebug:
  2. Install consoleexport:

To make consoleexport to send logs automatically to remote server you need to set three things in Firefox's about:config:

  1. = true to activate atomatic sending of logs to the remote server
  2. extensions.firebug.consoleexport.serverURL = ip:port to set remote server to which the logs are sent
  3. extensions.firebug.allPagesActivation = on to enable firebug on every page; only in that case cosoleexport will send automatically console logs to remote server

Note: DNS names are not resolved on the serverURL field, so you need to put IP there.

The above settings will cause headless Firefox to send console logs to the supplied remote server in XML format. Here is the code of the server written in NodeJS that prints sent log messages:

/* File: server.js
   Run with: node server.js
const express     = require('express');
const XmlStream   = require('xml-stream');
const bodyParser  = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({extended: true}));'/', (req,res)=>{
  var xml = new XmlStream(req);
  xml.on('endElement: msg', data=>{
  xml.on('end', ()=>{

If that server runs on then set extensions.firebug.consoleexport.serverURL=

Install lastest Oracle Java

Get Java from and install it. For example, JDK8u112 RPM is installed as

rpm -ivh jdk-8u112-linux-x64.rpm 

Verify Java version you're running after installation:

[root@NQPC003 ~]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
[root@NQPC003 ~]# 

Get and run Selenium standalone driver

Get Selenium from Running Selenium 3.0.1:

java -jar selenium-server-standalone-3.0.1.jar &

Make sure Selenium listens to connections:

[root@NQPC003 ~]# netstat -tlpn | grep 4444                                                                                 
tcp        0      0      *                   LISTEN      29040/java                           
[root@NQPC003 ~]#    

Automate headless Firefox


This comment has been minimized.

Copy link

commented May 24, 2018

I am installing firefox slightly differently. I'm manually putting it in /usr/local/ because there is an existing firefox installation that is being used by other automation tests. Did you have any issues with GTK3 not being available?

XPCOMGlueLoad error for file /usr/local/firefox60/ cannot open shared object file: No such file or directory
Couldn't load XPCOM.

This comment has been minimized.

Copy link

commented Aug 8, 2018

Running OEL 6.10

As soon as firefox is executed, xvfb aborts with a segmentation fault -
(EE) Backtrace:
(EE) 0: Xvfb (xorg_backtrace+0x51) [0x578381]
(EE) 1: Xvfb (0x400000+0x17c9f9) [0x57c9f9]
(EE) 2: /lib64/ (0x7f16007cb000+0xf7e0) [0x7f16007da7e0]
(EE) Segmentation fault at address 0x0
Fatal server error:
(EE) Caught signal 11 (Segmentation fault). Server aborting

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.