title: Setting default download directory and headless chrome
body: <p>I have a rails app, and am running capybara &amp; selenium, and using chrome for end-to-end testing. I want to set the default download directory while running chrome headless.</p>
  
  <p>Here's how I have it setup in my support/env.rb:</p>
  
  <pre><code>Capybara.register_driver :chrome do |app|
    Capybara::Selenium::Driver.new(app, :browser =&gt; :chrome)
  end
  
  Capybara.register_driver :headless_chrome do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    'chromeOptions' =&gt;  {
      'args' =&gt; %w(headless disable-gpu window-size=1920,1080),
      'prefs' =&gt; {
        'download.default_directory' =&gt; DownloadHelpers::PATH.to_s
      }
    }
  )
  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    #args: ["--window-size=1024,768"], #UNCOMMENT TO HAVE BROWSER WINDOW POP UP
    desired_capabilities: capabilities
  end
  </code></pre>
  
  <p>I have noticed that if I leave off </p>
  
  <pre><code>'args' =&gt; %w(headless disable-gpu window-size=1920,1080)
  </code></pre>
  
  <p>Then the default download directory is set, however, the browser automatically pops up, which I want to disable.</p>
  
  <p>When I have both:</p>
  
  <pre><code>    'args' =&gt; %w(headless disable-gpu window-size=1920,1080),
  'prefs' =&gt; {
    'download.default_directory' =&gt; DownloadHelpers::PATH.to_s
  }
  </code></pre>
  
  <p>It runs headless, but the default download path is not set.</p>
  
  <p>I have the following versions:</p>
  
  <p>capybara   (2.14.2)</p>
  
  <p>selenium-webdriver   (3.6.0) </p>
  
  <p>chromedriver-helper   (1.1.0) </p>