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

[ruby] Fix devtools version fallback #11869

Merged

Conversation

robotdana
Copy link
Contributor

Description

When using the feature added in #11827 that loads devtools methods possibly a version or two earlier than was necessary asked for, i was seeing this error:

NoMethodError: undefined method `get_targets' for nil:NilClass
./rb/lib/selenium/webdriver/devtools.rb:75:in `start_session'
./rb/lib/selenium/webdriver/devtools.rb:34:in `initialize'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `new'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `devtools'

because target was nil because it was trying to load a class named:

Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}

which resolved to:

Selenium::DevTools::V112::Target

even though the falling-back code had already given up on 112 and loaded 111 instead.

The simplest way to fix this seems to be ensure that Selenium::DevTools.version matches what was loaded.

Also now there's a test

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

When using the feature added in SeleniumHQ#11827 that loads devtools methods
possibly a version or two earlier than was necessary asked for, i was
seeing this error:

```
NoMethodError: undefined method `get_targets' for nil:NilClass
./rb/lib/selenium/webdriver/devtools.rb:75:in `start_session'
./rb/lib/selenium/webdriver/devtools.rb:34:in `initialize'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `new'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `devtools'
```
because `target` was nil because it was trying to load a class named:
```
Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}
```
which resolved to:
```
Selenium::DevTools::V112::Target
```
even though the falling-back code had already given up on 112 and loaded
111 instead.

The simplest way to fix this seems to be ensure that
`Selenium::DevTools.version` matches what was loaded.

Also now there's a test
@CLAassistant
Copy link

CLAassistant commented Apr 6, 2023

CLA assistant check
All committers have signed the CLA.

@robotdana robotdana changed the title Fix ruby devtools version fallback [ruby] Fix devtools version fallback Apr 6, 2023
@titusfortner
Copy link
Member

Ah, yes, we should make sure we are only using fallbacks if the version is greater than what is available.

@titusfortner
Copy link
Member

Ok, I see what this is now. Thanks for the code and the test!

@titusfortner titusfortner merged commit 0745668 into SeleniumHQ:trunk Apr 7, 2023
yashcho pushed a commit to yashcho/selenium that referenced this pull request Apr 7, 2023
Fix ruby devtools version fallback

When using the feature added in SeleniumHQ#11827 that loads devtools methods
possibly a version or two earlier than was necessary asked for, i was
seeing this error:

```
NoMethodError: undefined method `get_targets' for nil:NilClass
./rb/lib/selenium/webdriver/devtools.rb:75:in `start_session'
./rb/lib/selenium/webdriver/devtools.rb:34:in `initialize'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `new'
./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:35:in `devtools'
```
because `target` was nil because it was trying to load a class named:
```
Selenium::DevTools::V#{Selenium::DevTools.version}::#{method.capitalize}
```
which resolved to:
```
Selenium::DevTools::V112::Target
```
even though the falling-back code had already given up on 112 and loaded
111 instead.

The simplest way to fix this seems to be ensure that
`Selenium::DevTools.version` matches what was loaded.

Also now there's a test
@robotdana robotdana deleted the ruby-devtools-version-inconsistency branch April 8, 2023 00:21
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

Successfully merging this pull request may close these issues.

None yet

3 participants