Closed darinwilson closed 1 year ago
Just want to add that I solved the error originally posted in this issue by updating Capybara from 3.39.0 -> 3.39.2 And I ditched webdrivers and only use selenium-webdriver (but that alone did not fix it - the capybara upgrade was the key).
Just a note incase others find this useful.
We are precaching our webdrivers on CI (GH Actions) - as such we have to fix the precached version using:
bundle exec rake webdrivers:chromedriver:update[114.0.5735.90]
^^ interestingly the above cmd running locally using using ZSH fails (zsh: no matches found: webdrivers:chromedriver:update[114.0.5735.90]
) - but works fine using bash
^^ interestingly the above cmd running locally using using ZSH fails (
zsh: no matches found: webdrivers:chromedriver:update[114.0.5735.90]
) - but works fine using bash
That's because [] are reserved characters in zshell. If you do: bundle exec rake webdrivers:chromedriver:update\[114.0.5735.90\]
in zsh it should work.
@ryanb posted this but it is distinct from the error I am seeing.
https://ryanbigg.com/2023/07/how-to-fix-chromedriver-115-cannot-find-chrome-binary
in fact, his fix here does not seem to work for me (even though I think it should)
If I set required_version to the old one (114.0.5735.90), it seems to use the old one OK
if I leave off the required_version completely (unset) , I get
1) homepage can load
Failure/Error: visit '/'
Webdrivers::VersionError:
Unable to find latest point release version for 115.0.5790. You appear to be using a non-production version of Chrome. Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html
However, if I explicitly set the require_version to Webdrivers::Chromedriver.required_version = '115.0.5790.102'
, then I get:
Failure/Error: visit '/'
Webdrivers::NetworkError:
Net::HTTPServerException: 404 "Not Found" with https://chromedriver.storage.googleapis.com/115.0.5790.102/chromedriver_mac_arm64.zip
odd. it seems like Ryan's fix should work
@jasonfb that's a different bug. This gem does not know how to get v115, so you can't set the required version to 115, and you can't allow it to look for 115. Even if it did get v115, it wouldn't work on Mac for the reasons listed in that blog.
Thanks for the conversation and feedback here. I've sketched out my thoughts/recommendations on where I think this project should go in this PR — https://github.com/titusfortner/webdrivers/pull/251
If anyone wants to provide feedback there, please do.
Upgrading to 5.2.0 did not work in my case, maybe because I'm using terminal in Rosetta mode on an M2?
What did work was the following, and I'm writing it up here as it looks like from Chrome 116 webdrivers should be supporting the new "Google Chrome for Testing" binaries that Google will be releasing (see https://developer.chrome.com/blog/chrome-for-testing/ for more details) going forward.
Download "Google Chrome for Testing" and it's corresponding chromedriver:
npx @puppeteer/browsers install chrome@stable
npx @puppeteer/browsers install chromedriver@stable
NB. These commands will simply create directories that contain the binaries in whichever directory you run them from.
Place "Google Chrome for Testing.app" and "chromedriver" into a folder like "~/.chrome"
Add the folder to your PATH, in my case (using ZSH) it was:
export PATH=${PATH}:/Users/$USER/.chrome
Restart your terminal
Remove the webdrivers
gem from your Gemfile
(sorry!) and run bundle
Run tests and see them working with "Google Chrome for Testing"
I realise this is totally bypassing webdrivers
, but wanted to post it here for consideration to build in support for future versions as I'd love to see traditional webdrivers
functionality working with "Google Chrome for Testing".
@thomasgallagher upgrading to 5.2 is not a suggested solution for anything. There should be a partial fix in 5.3, but it isn't released yet.
The recommendation in this issue is to remove this gem and use the latest version of Selenium to manage drivers for you. A combination of JavaScript and PATH could work, but shouldn't be needed.
Thanks @titusfortner , your comment at https://github.com/titusfortner/webdrivers/issues/247#issuecomment-1650315937 explains things well for me.
While all my personal apps are running on ruby 3.0, I do still have some gems I maintain that I have been running CI on (on Github Actions) for 2.7, out of courtesy to my users. (I try to drop ruby versions only on major releases, when I can).
selenium-webdriver's 4.10.0 can not be used on ruby 2.7. The latest webdrivers
can be -- even if maintainers aren't intending to support ruby 2.7, it does not have anything in the gemspec forbidding it, and works for us.
I am still not certain if there's any planned solution for ruby 2.7?
If not, it looks like @mascolim's fork at https://github.com/mascolim/webdrivers/tree/jsonendpoints is the best bet for continuing to use selenium chrome with ruby 2.7?
Or, it looks like maybe #251 suggests that there will be a future version of webdrivers that can download chrome driver from the right places, perhaps basically merging mascolim's logic? I'm not totally sure if it's expected that will be a solution for those still testing on ruby 2.7?
I am still very confused about a) if there's anything I can do right now to get my ruby 2.7 builds green again, and b) if there are expected future releases that will make same easier.
(This whole situation is even more confusing than usual, due to several different challenges happening simultaneously. When it rains it pours).
@jrochkind. My projects support what Ruby supports. Selenium doesn't even practice SemVer (it's not worth it with a multi-language mono-repo), and in my other projects I do major releases only for backwards incompatible changes, not for keeping up with Ruby. Though, in this case, this gem hasn't been updated for a while, so it still supports 2.6, and there's no reason for me to change that given the current situation. It still needs Selenium 4.0, so the minimum will remain selenium 4+ and Ruby 2.6+.
a) if there's anything I can do right now to get my ruby 2.7 builds green again
Yes, set required version to 114.0.5735.90
. That option and all the future plans are specified here — #251 — but you raise a good point that it doesn't mention minimum required versions, so I'll update that.
OK, thanks @titusfortner.
Yes, set required version to 114.0.5735.90.
I guess this will work as long as the version of Chrome that exists on the system is compatible with this verison of chromedriver? I actually am not sure what determines what version of Chrome is on, say, Github Actions environment, or when it might change -- the magic of webdrivers approach (when it works) is that it has kind of Just Worked without having to pay attention to the details and how it matches host environment -- and I think selenium-webdrivers sounds like it will do this even better.
For those who desire to keep running CI with selenium and chrome under ruby 2.7 (as they could with webdrivers
until Chrome changed location of some content recently) -- it sounds like @mascolim's fork linked above might be a good solution. I am getting confused thinking of all the various permutations and effects, but I'll play with it and see where it gets me. Thanks @mascolim for the option!
@jrochkind yes this is more confusing than it should be.
I guess this will work as long as the version of Chrome that exists on the system is compatible with this verison of chromedriver
ChromeDriver version matches the same version of Chrome or V+1 of Chrome (to give users time to upgrade). If you want to match more broadly, you have to pass in an argument to ignore the build check.
Github Actions has the driver on PATH, and that gets used if webdrivers is not used. I think it's still set at Chrome v114 for the same reasons everyone else is scrambling to change where they get drivers/browsers. 😄
Webdrivers will continue to support Ruby 2.6+ (I previously thought I'd updated this, but I did not and there's no reason to do so now). Chrome v115 support in this gem hopefully out later today.
I appreciate the fork provided by @mascolim. Unfortunately we used a newer version of webdrivers
but still could not update to the latest version of selenium-webdriver
and were stuck around gem 'selenium-webdriver', '~> 4.0.3'
since we need to update things to Rails 6. This made it so we could not use the Selenium 3 based updates (Incompatible with Selenium 4+). That's all a mouthful, but I am done trying to describe the annoying version interplay.
For Selenium 4+ support, I made a patch based on that fork for the case you are using a selenium-webdriver
gem > 4.0 but less than the latest release, and are relying on a webdrivers
gem > 4.5.0. Link below for the off chance someone else is in the same painful scenario.
See: https://github.com/n8williams/webdrivers
UPDATE: If you update to 5.3, this is likely not needed! gem 'webdrivers', '~> 5.3.0'
@n8williams for clarity, what keeps you from using webdrivers 5.3?
I tried using selenium-webdriver directly, but the thing is, that we need to configure
VCR
to ignore requests to the webdriver URLs (see also https://blog.pablobm.com/2021/10/14/vcr-webdriver-errors.html:
@rnestler - I am passing this literal - but I am not really sure what the actual URL is.
VCR.configure do |config|
config.ignore_hosts('github-releases.githubusercontent.com')
I need to look through the selenium-webdriver
source for its Webdrivers::Common
cousin.
@brentgreeff it's in the rust code. e.g., this is chrome - https://github.com/SeleniumHQ/selenium/blob/trunk/rust/src/chrome.rs
@n8williams for clarity, what keeps you from using webdrivers 5.3?
@titusfortner My inability to read relevant comments, and the latest Changelog are what kept me from using 5.3
😄 🤦 I really appreciate the updates, that did the trick. I'll edit my comment for currentness. Though it is odd the releases section on the homepage for github is on 5.2, but the gem page is up to date.
5.3
did the trick until we can update our selenium-webdriver
gem.
Oh, I forgot to update that. Thank you for pointing it out!
Fixed releases.
My workaround for this on ruby 2.72, capybara: 3.37.1, selenium-webdriver: 4.9.0, webdrivers: 5.2.0:
Capybara.server = :webrick
Capybara.register_driver :selenium_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions'=> {"args" => ['headless'] }
)
service_args = %w[--disable-build-check]
service = Selenium::WebDriver::Service.chrome(args: service_args)
Capybara::Selenium::Driver.new(
app,
:browser => :chrome,
:capabilities => capabilities,
:service => service
)
end
Capybara.javascript_driver = :selenium_chrome
Webdrivers::Chromedriver.required_version = '114.0.5735.90'
thanks for the inspo: https://twitter.com/jeremysmithco/status/1695089140373553266
@ecpantalone Why not just use 5.3.1?
@dougc84 client has a small budget and we're going to prioritize the upgrades later -- for now, this worked
@ecpantalone you don't need a workaround or to upgrade things to get it to work with 5.3 Thanks for posting the Twitter link, I replied there as well
PRs welcomed.
Or if you are using one of the latest versions of Selenium, you shouldn't need to require this gem any more. 😄
This worked for me. I for some reason still had the webdrivers
gem in my Gemfile along with the selenium-webdriver
gem. Once I deleted the webdrivers
gem and ran bundle update
, this error went away. Thank you for your solution.
This worked for me, deleted the webdrivers
gem and ran bundle update selenium-webdriver
and added following in rails_helper
Capybara.register_driver :headless_chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.add_option('w3c', false)
%w[headless window-size=1280x1280 disable-gpu].each { |arg| options.add_argument(arg) }
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
end
@pramodshinde
This shouldn't be used and should raise an exception: options.add_option('w3c', false)
disable-gpu
hasn't been needed for a few years, and it is suggested that you use headless=new
now (https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md#headless)
@pramodshinde This shouldn't be used and should raise an exception:
options.add_option('w3c', false)
disable-gpu
hasn't been needed for a few years, and it is suggested that you useheadless=new
now (https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md#headless)
Thanks, I will try without these options, and update 👍
For anyone else stuck on Ruby 2.7 and Selenium 4.9 - we ran into an issue this week where selenium-manager could no longer find the right driver (maybe because chrome 120 is more than 5 versions ahead of 114 now 🤷 ). So we ended up adding back the webdrivers gem, v5.x, with the disable-build-check
flag and it solved the problem.
Selenium 4.11+ is needed to access the chrome for testing repository.
You should get an error if the browser is 2+ versions ahead of the driver
What @kmazanec suggested work also for my rails app (Ruby 2.7, selenium-webdriver (4.9.0), webdrivers (5.3.1)). What i additionally needed to do was:
WebMock.disable_net_connect!(
allow_localhost: true,
allow: [
'https://storage.googleapis.com',
'https://googlechromelabs.github.io'
]
)
As the app is using webmock.
The Webdrivers::Chromedriver.required_version = "114.0.5735.90"
fix is no longer working as of today
Google Chrome is not currently installed; installing it
Preparing Chrome installation for Debian-based systems
https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_114.0.5735.90-1_amd64.deb:
2024-05-16 13:08:46 ERROR 404: Not Found.
/bin/bash: line 129: google-chrome-stable: command not found
Google Chrome v114.0.5735.90 (stable) failed to install.
Summary
Apologies if this is a dupe of #180 but when running CI on Travis, tests are failing with
Webdrivers::VersionError: Unable to find latest point release version for 115.0.5790
- that version does not appear to exist yet (latest is 114)Debug Info
Expected Behavior
Webdrivers should download latest available version
Actual Behavior
Test fails with the error shown above. This works locally on Apple silicon (I deleted my cached browsers under
~/.webdrivers
and ran tests successfully), but not on Travis.Thank you!