# frozen_string_literal: true

require "find_chrome"

Capybara.register_driver :headless_chrome do |app|
  profile = Selenium::WebDriver::Chrome::Profile.new
  profile["general.useragent.override"] =
    "Mozilla/5.0 (X11; Linux x86_64; MichiganBenefits.org) "\
    "AppleWebKit/537.36 (KHTML, like Gecko) "\
    "Chrome/60.0.3112.101 Safari/537.36"

  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    profile: profile,
    chromeOptions: {
      args: %w[headless disable-gpu],
      binary: FindChrome.binary,
    },
  )

  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    desired_capabilities: capabilities,
    driver_path: FindChrome.driver,
  )
end

# frozen_string_literal: true

require "find_chrome"

Capybara.register_driver :headless_chrome do |app|
  profile = Selenium::WebDriver::Chrome::Profile.new
  profile["general.useragent.override"] =
    "Mozilla/5.0 (X11; Linux x86_64; MichiganBenefits.org) "\
    "AppleWebKit/537.36 (KHTML, like Gecko) "\
    "Chrome/60.0.3112.101 Safari/537.36"

  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    profile: profile,
    chromeOptions: {
      args: %w[headless disable-gpu no-sandbox],
      binary: FindChrome.binary,
    },
  )

  Capybara::Selenium::Driver.new(
    app,
    browser: :chrome,
    desired_capabilities: capabilities,
    driver_path: FindChrome.driver,
  )
end

Add no-sandbox option to headless chrome driver
Add no-sandbox option to headless chrome driver

It looks as if heroku needs this option set in order for it to run on
their dynos
