My Capybara Selenium Webdriver set up is failing when trying to make a connection to ChromeDriver - It appears they released a version without an M1 version to find at the Chromedriver API https://chromedriver.storage.googleapis.com/index.html?path=106.0.5249.61/
Webdrivers::NetworkError:
Net::HTTPServerException: 404 "Not Found" with https://chromedriver.storage.googleapis.com/106.0.5249.61/chromedriver_mac64_m1.zip
Capybara.register_driver :headless_chrome do |app|
options.add_argument("--disable-gpu")
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--window-size=1920,1080")
driver = Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
### Allow file downloads in Google Chrome when headless
### https://bugs.chromium.org/p/chromium/issues/detail?id=696481#c89
bridge = driver.browser.send(:bridge)
path = "/session/:session_id/chromium/send_command"
path[":session_id"] = bridge.session_id
bridge.http.call(:post, path, cmd: "Page.setDownloadBehavior",
params: {
behavior: "allow",
downloadPath: "/tmp/downloads",
})
###
driver
end
When the application calls driver.browser I get the error above and that is because the file it's looking for does not exist.
Can I set a specific version of chrome driver or what system to look for when initializing the driver?
I got an apple silicon mac and still had the old (intel) chromedriver. To solve, I had to:
You may only need to do the second step, depending on whether you already have the apple silicon chromedriver installed. See below for how to check.
Run these two commands and if the output looks like below, you have the apple silicon chromedriver installed and can skip to updating the webdrivers gem:
which chromedriver
# /opt/homebrew/bin/chromedriver
file $(which chromedriver)
# /opt/homebrew/bin/chromedriver: Mach-O 64-bit executable arm64
But if the output is something like this, you still have the intel version of chromedriver and need to update to the apple silicon version:
which chromedriver
# /usr/local/bin/chromedriver
file $(which chromedriver)
# /usr/local/bin/pandoc: Mach-O 64-bit executable x86_64
To install the apple silicon chromedriver:
brew install --cask chromedriver
In a new terminal window run which chromedriver and file $(which chromedriver) again to check it now shows apple silicon (arm) versions.
If you get an error from Apple:
“chromedriver” can’t be opened because Apple cannot check it for malicious software.
Just run this and try again:
xattr -d com.apple.quarantine $(which chromedriver)
The webdrivers gem must be >= 5.2.0 so it knows where to look for the apple silicon chromedriver.
In my Gemfile was this:
gem "webdrivers"
so I changed it to:
gem "webdrivers", "~> 5.2.0"
bundle install, and everything works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With