run selenium with chrome driver on heroku: `cannot find Chrome binary`
ChromeDriver is just a driver for Chrome. It needs the actual Chrome browser installed on the same machine to actually work.
Heroku doesn't have Chrome installed on its dynos by default. You need to use a buildpack that installs Chrome. For example:
https://github.com/dwayhs/heroku-buildpack-chrome
You can see how it fetches Chrome:
https://github.com/dwayhs/heroku-buildpack-chrome/blob/master/bin/compile#L36-38
Chrome binary not found on Heroku with Selenium for Ruby on Rails
I'm guessing you upgraded to the latest selenium-webdriver and chromedriver in the last few weeks. chromeOptions
is no longer a valid key to pass, you can try changing it to goog:chromeOptions
but you really should just be using an instance of the Selenium::WebDriver::Chrome::Options
class
Capybara.register_driver :chrome do |app|
options = ::Selenium::WebDriver::Chrome::Options.new
options.binary = ...
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
Heroku: Unable to find chromedriver when using Selenium
The way to do it is:
Add the buildpacks with
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-google-chrome
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-chromedriverAdd the env vars
GOOGLE_CHROME_BIN
andGOOGLE_CHROME_SHIM
in Heroku both with value/app/.apt/opt/google/chrome/chrome
i.e.heroku config:set GOOGLE_CHROME_BIN=/app/.apt/opt/google/chrome/chrome
heroku config:set GOOGLE_CHROME_SHIM=/app/.apt/opt/google/chrome/chromeUse watir in the following way
args = %w[--disable-infobars --headless window-size=1600,1200 --no-sandbox --disable-gpu]
options = {
binary: ENV['GOOGLE_CHROME_BIN'],
prefs: { password_manager_enable: false, credentials_enable_service: false },
args: args
}
@browser = Watir::Browser.new(:chrome, options: options)
Related Topics
How to Return a Fixed Length Binary Representation of an Integer in Ruby
How to Join a Table and Count Records in Rails 3
Rails Installation Error :The 'Atomic' Native Gem Requires Installed Build Tools
How to Do Complex Querying with Logical Operations by Using Searchkick
Postgresql Ilike with Multiple Matches in Rails Activerecord
Ruby on Rails Collection Select - How to Pre-Select the Right Value
Linux Cli: How to Render Arabic Text into Bitmap
Ruby Yaml Parser by Passing Constructor
Alternative for Accepts_Nested_Attributes_For - Maybe Virtus
Rvm with Jruby 1.7.0 "Unknown Ruby Interpreter"
How to Use Ffmpeg on a Remote Machine via Ssh
Git Post-Receive Hook Not Running Bundle Install
"Interfaces & Abstract Classes Unnecessary in Ruby" -> Can Someone Explain
Rails Console Fails with 'Switch to Inspect Mode' in Windows