Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver version cache exception for Chrome does not work #171

Closed
davidstosik opened this issue May 22, 2020 · 4 comments
Closed

Driver version cache exception for Chrome does not work #171

davidstosik opened this issue May 22, 2020 · 4 comments

Comments

@davidstosik
Copy link

davidstosik commented May 22, 2020

Summary

From the README:

Special exception for chromedriver and msedgedriver

Cache time will be respected as long as a driver binary exists and the major versions of the browser and the driver match. For example, if you update Chrome or Edge to v76 and its driver is still at v75, webdrivers will ignore the cache time and update the driver to make sure you're using a compatible version.

I've just experienced a scenario where that did not happen.

Debug Info

Please provide the following information for bug reports:

  • Webdrivers version: 4.3.0
  • Ruby version: 2.6.6
  • Operating system / CI Environment: macOS Catalina
  • Browser and version: Google Chrome 83.0.4103.61

Here's all the debugging data I have:

Chrome version:
image

# Running rspec on a Rails project's feature spec that runs chrome driver:
$ bin/rspec spec/features/someting_spec.rb
...
     1.2) Failure/Error: spec.run
          Selenium::WebDriver::Error::SessionNotCreatedError:
            session not created: This version of ChromeDriver only supports Chrome version 81
...

$ ~/.webdrivers/chromedriver --version
ChromeDriver 81.0.4044.138 (8c6c7ba89cc9453625af54f11fd83179e23450fa-refs/branch-heads/4044@{#999})

$ ruby -r"webdrivers/chromedriver" -e "%i(latest_version chrome_version current_version required_version).each{|m|puts Webdrivers::Chromedriver.send(m)}"
81.0.4044.138
83.0.4103.61
81.0.4044.138
0

$ ruby -r"webdrivers/chromedriver" -e "puts Webdrivers::VERSION"
4.3.0

$ ruby -r"webdrivers/chromedriver" -e "puts Webdrivers::ChromeFinder.version"
83.0.4103.61

$ RAILS_ENV=test rails webdrivers:chromedriver:update
2020-05-22 13:05:42 INFO Webdrivers Updated to chromedriver 81.0.4044.138

$ cat ~/.webdrivers/chromedriver.version
81.0.4044.138

I have a hunch the ~/.webdrivers/chromedriver.version cache file was created within the last 24 hours, but cannot confirm that, as it was deleted in order to fix the problem.

Expected Behavior

Having Chrome 83.* running, while chromediver is at version 81.*, I would expect, as mentioned in the README, that the version number cache would be ignored, and chromedriver updated to its latest version 83.*, "to make sure [I'm] using a compatible version".

Actual Behavior

The following error is raised:

          Selenium::WebDriver::Error::SessionNotCreatedError:
            session not created: This version of ChromeDriver only supports Chrome version 81

Deleting ~/.webdrivers/chromedriver.version fixed the issue.

@kapoorlakshya
Copy link
Collaborator

kapoorlakshya commented May 23, 2020

@davidstosik Thank you for the detailed bug report. I am able to reproduce it by following your steps.

What's interesting is that we have an unit test for this exact scenario, which is passing (/spec/webdrivers/chromedriver_spec.rb:109). I haven't looked at the caching related code in a while, so I'll try to make time this weekend to debug this issue. However, a PR to fix this from you or anyone else is always welcome!

@kapoorlakshya
Copy link
Collaborator

kapoorlakshya commented May 25, 2020

@davidstosik I have updated the specs to catch this bug and also have a possible fix that passes the test you shared:

$ bin/console
irb(main):001:0> `cat "C:/Users/Lakshya Kapoor/.webdrivers/chromedriver.version"`
=> "81.0.4044.138"

irb(main):002:0> File.mtime "C:/Users/Lakshya Kapoor/.webdrivers/chromedriver.version"
=> 2020-05-24 19:20:10 -0700

irb(main):003:0> %i(latest_version chrome_version current_version required_version).each{ |m| puts Webdrivers::Chromedriver.send(m) }
83.0.4103.39 # latest driver version
83.0.4103.61 # my Chrome version
81.0.4044.138 # current driver version
0 # required version
=> [:latest_version, :chrome_version, :current_version, :required_version]

irb(main):004:0> Webdrivers::Chromedriver.update
=> "C:/Users/Lakshya Kapoor/.webdrivers/chromedriver.exe"

irb(main):005:0> `cat "C:/Users/Lakshya Kapoor/.webdrivers/chromedriver.version"`
=> "83.0.4103.39"

irb(main):006:0> File.mtime "C:/Users/Lakshya Kapoor/.webdrivers/chromedriver.version"
=> 2020-05-24 19:21:34 -0700

As you can see, the default cache timeout value of 24 hours was ignored and the latest compatible driver version for Chrome 83.0.4103 was downloaded. I'll push the fix to master once I'm done testing it locally.

@kapoorlakshya
Copy link
Collaborator

@davidstosik I just pushed the fix (564907d) to master. And the specs were updated in fcea4dc. Would you mind loading the gem from the master branch and running through some tests of your own? Just want to get another set of eyes on the fix before I release it.

If everything looks good, I'll try to push out a patch release within this week.

@kapoorlakshya
Copy link
Collaborator

v4.4.0 has been released with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants