2

I'm trying to run selenium tests on a headless redhat linux build machine using firefox headless. My method to create the driver looks as so:

private static WebDriver createFireFoxDriver() {
    WebDriverManager.firefoxdriver()
            .setup();

    FirefoxOptions options = new FirefoxOptions();
    options.setHeadless(true);
    options.addPreference("browser.download.folderList", 2);
    options.addPreference("browser.download.dir", ABSOLUTE_PATH_TO_FOLDER);
    options.addPreference("browser.download.manager.showWhenStarting", false);
    options.addPreference("browser.helperApps.neverAsk.saveToDisk", "application/json");

    return new FirefoxDriver(options);
}

The error I'm seeing in the log files looks like:

[Parent 65433, Gecko_IOThread] WARNING: pipe error (82): Connection reset by peer: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 358
[Parent 65433, Gecko_IOThread] WARNING: pipe error: Broken pipe: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 727

###!!! [Parent][MessageChannel] Error: (msgtype=0x1E0074,name=PBrowser::Msg_StopIMEStateManagement) Channel error: cannot send/recv


###!!! [Parent][MessageChannel] Error: (msgtype=0x1E008F,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv

1579539977190   Marionette  TRACE   [11] Frame script loaded
1579539977191   Marionette  TRACE   [11] Frame script registered
A content process crashed and MOZ_CRASHREPORTER_SHUTDOWN is set, shutting down

I've checked that we have the correct versions of gtk, glib, pango, xorg, and libstdc++ installed on the machine as well. Has anyone run into this problem before with a headless build machine?

Firefox version: 68.4.1 | Selenium version: 3.141.59 | Geckdriver version: 0.26.0

Digging deeper into the test that is causing the crash. Right before the crash occurs the test is clicking on SwaggerUI's API try functionality. No other action on the site causes this crash to happen.

st0ve
  • 519
  • 3
  • 18

2 Answers2

1

Found a solution that works as well as the root cause.

When running firefox within a linux docker container, /dev/shm must have at least 2gb. My build machine configuration was not meeting this requirement. Increasing the amount of memory to a value over 2gb solved my problem immediately.

The reason for this behaviour is that Firefox uses POSIX shared memory which on Linux (according to the shm_open(3) man page) is based on tmpfs (expected to be) mounted on /dev/shm. Open shared memory objects/interfaces can be listed with the ipcs or lsof utilities.

peterph
  • 980
  • 6
  • 11
st0ve
  • 519
  • 3
  • 18
0

I don't see any version misatch in the binaries you are using with respect to the discussion in Which Firefox browser versions supported for given Geckodriver version?.

The sole suspect is the setHeadless() method of FirefoxOptions class which as per documentation is as follows:

setHeadless(boolean headless)

So effectively, your code block will be:

FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true)

Update

Additionally the Keys:

  • browser.download.folderList
  • browser.download.dir
  • browser.download.manager.showWhenStarting
  • browser.helperApps.neverAsk.saveToDisk

needs to be configured through setPreference() method using an instance of FirefoxProfile() as follows:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", ABSOLUTE_PATH_TO_FOLDER);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/json");

You can find a relevant detailed discussion in How to auto-download through Firefox browser using FirefoxProfile?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352