heroku/heroku-buildpack-google-chrome

Example Ruby in README code is out of date

xaviershay opened this issue · 0 comments

I'm not sure what the correct way to do it is now, but the following appears to work for me (noting the redundant setting of path). Loathe to submit a PR when I don't actually understand how it all works...

chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil)

options = Selenium::WebDriver::Chrome::Options.new
# ... I don't think this does anything
options.binary = chrome_bin if chrome_bin

# Discovered this by spelunking in the webdrivers code. I'm not really sure
# how all these gems interact...
Selenium::WebDriver::Chrome.path = chrome_bin

# Comment out for debugging
options.add_argument('--headless')

Capybara.register_driver :chrome do |app|
  Capybara::Selenium::Driver.new(
     app,
     browser: :chrome,
     options: options
  )
end