Capybara, Chrome Headless: File Download is not working

I am trying to download a file with chrome headless.
My Chrome version is 67.0.3396.87 and my chromedriver has the 2.4.

The file does not appear on my file system. As far as i researched, its a safety function of chrome headless to prevent file downloads, but which can be turned on again.

Thats what i tried to do, regarding to this Thread:

Still nothing works. I tried different approaches with


eg. i copied the content of comment 78 but Chrome does not respond to it, or atleast it still does not work:

def enable_chrome_headless_downloads(driver, directory)
  bridge = driver.send(:bridge)
  path = '/session/:session_id/chromium/send_command'
  path[':session_id'] = bridge.session_id, path, {
    "cmd" => "Page.setDownloadBehavior",
    "params" => {
      "behavior" => "allow",
      "downloadPath" => directory,

I also checked if i could download manually a file with headless chrome with


but it was not possible either.
Has anyone an idea, what I could do to make it work?

Thanks already!

setting chrome ‘devtools.open_docked’ to false in selenium webdriver

I am want the chrome devtools to open detached from the window when using selenium with capybara.

Currently devtools is attached to the right side (default.)

I am using the following code:

Capybara.register_driver :chrome do |app|
  capabilities =
    chromeOptions: { 
      args: %w[auto-open-devtools-for-tabs], # <- this works!
      prefs: {'devtools.open_docked' => false} # <- has no effect!
      # also tried {devtools: {open_docked: false}}
    app, browser: :chrome, desired_capabilities: capabilities