1

I'm getting the following error when I try to open the Firefox in headless mode:

Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port
7055; process output follows:

(process:27527): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Xlib: extension "RANDR" missing on display ":1".

(firefox:27527): GConf-WARNING **: Client failed to connect to the D-BUS daemon:
Failed to connect to socket /tmp/dbus-VBJDTHN8W2: Connection refused
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
System info: host: 'cpro22808', ip: '176.153.5.11', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-32-generic', java.version:
'1.7.0_55'

Driver info: driver.version: FirefoxDriver

I'm using Ubuntu 14.04, Firefox 33, Selenium 2.44, Tomcat7, Xvfb.

I'm starting the Xvfb like that:

Xvfb :1 -ac -screen 0 1024x768x24

My java code:

String Xport = System.getProperty("lmportal.xvfb.id", ":1");
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);
webDriver = new FirefoxDriver(firefoxBinary, null);

I spent several days on this and tried a lot of things and nothing solve. Can someone help me?

NeoRamza
  • 151
  • 1
  • 11
  • make sure you are using compatible selenium and firefox versions – CharlieS Oct 29 '14 at 06:51
  • Yes, I did. Thats is why I talked about the versions in the post. I also tryed firefox 28 with selenium 2.41, and I get the same error. Thanks for your reply. – NeoRamza Nov 02 '14 at 17:06
  • can you attach to display :1 by starting firefox from the command line? Have you tried a different display value? I let jenkins and maven handle this, but generally use display :2 onwards – CharlieS Nov 03 '14 at 01:22
  • the error is common with version incompatibilities. – CharlieS Nov 03 '14 at 01:23

2 Answers2

4

I was also facing the same problem. This is what I did and the problem is gone.

  1. Delete /var/lib/dbus/machine-id. It will recreate a correct one on its one.
  2. export $(dbus-launch) and export NSS_USE_SHARED_DB=ENABLED. Set these environment variables and then re-run.

The issue was gone in my case.

Gustavo Morales
  • 2,614
  • 9
  • 29
  • 37
Sarvesh Agarwal
  • 181
  • 1
  • 4
0

That's a good solution but at the end I discovered another option without the need of launching dbus. You can instead disable the logging of geckodriver with -Dwebdriver.firefox.logfile=/dev/null system property.

Curiously I could pass it from command line, but I had to explicitly set it before instantiating the FirefoxDriver:

    System.setProperty(FirefoxDriver.SystemProperty.BROWSER_LOGFILE, "/dev/null");
    FirefoxDriver driver = new FirefoxDriver(firefoxOptions);

The drawback is that you lose also any other log, but I like the fact that you don't need to run dbus-daemon.

riccardo.tasso
  • 978
  • 2
  • 10
  • 28