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 Chrome::Options.process_browser_options #8410

Merged

Conversation

masakazutakewaka
Copy link
Contributor

Description

It errors when an Options instace with profile is passed to Driver.new in 'capabilities' key:

# cd /path/to/rb
$ bundle exec rails c
profile   = Selenium::WebDriver::Chrome::Profile.new
options = Selenium::WebDriver::Chrome::Options.new(profile: profile)
driver    = Selenium::WebDriver.for :chrome, capabilities: [options]

Traceback (most recent call last):
        1: from (irb):6
NoMethodError (undefined method `split' for :directory:Symbol)

Motivation and Context

passing an Array of options to Driver.new in :capabilities key is still a valid option when initializing a driver, so I suppose fixing this is important.

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.

@masakazutakewaka masakazutakewaka changed the title fix Chrome::Options.process_browser_options Fix Chrome::Options.process_browser_options Jun 10, 2020
@@ -208,6 +208,14 @@ def as_json(*)
expect { Driver.new(capabilities: [options]) }.not_to raise_exception
end

it 'with Options instance with profile' do
Copy link
Contributor Author

@masakazutakewaka masakazutakewaka Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

confirmed this test case fails with master.

$ bundle exec rspec spec/unit/selenium/webdriver/chrome/driver_spec.rb:211
...

Failures:

  1) Selenium::WebDriver::Chrome::Driver with :capabilities when value is an Array with Options instance with profile
     Failure/Error: expect { Driver.new(capabilities: [options]) }.not_to raise_exception

       expected no Exception, got #<NoMethodError: undefined method `split' for :directory:Symbol> with backtrace:
         # ./lib/selenium/webdriver/chrome/profile.rb:60:in `[]'
         # ./lib/selenium/webdriver/chrome/options.rb:188:in `process_browser_options'
         # ./lib/selenium/webdriver/common/options.rb:81:in `as_json'
         # ./lib/selenium/webdriver/common/driver.rb:344:in `block in generate_capabilities'
         # ./lib/selenium/webdriver/common/driver.rb:332:in `map'
         # ./lib/selenium/webdriver/common/driver.rb:332:in `generate_capabilities'
         # ./lib/selenium/webdriver/common/driver.rb:320:in `create_bridge'
         # ./lib/selenium/webdriver/common/driver.rb:76:in `initialize'
         # ./spec/unit/selenium/webdriver/chrome/driver_spec.rb:216:in `new'
         # ./spec/unit/selenium/webdriver/chrome/driver_spec.rb:216:in `block (5 levels) in <module:Chrome>'
         # ./spec/unit/selenium/webdriver/chrome/driver_spec.rb:216:in `block (4 levels) in <module:Chrome>'
     # ./spec/unit/selenium/webdriver/chrome/driver_spec.rb:216:in `block (4 levels) in <module:Chrome>'

It errors when an Options instace with profile is passed to Driver.new in 'capabilities' key
@masakazutakewaka masakazutakewaka force-pushed the rb-fix-browser-creation-with_profile branch from 7e411d3 to 315bee9 Compare June 10, 2020 14:55
@masakazutakewaka masakazutakewaka changed the title Fix Chrome::Options.process_browser_options [ruby] Fix Chrome::Options.process_browser_options Jun 11, 2020
@p0deje p0deje merged commit 6f36f8e into SeleniumHQ:master Jun 11, 2020
@p0deje
Copy link
Member

p0deje commented Jun 11, 2020

Thanks you for the contribution!

titusfortner pushed a commit to titusfortner/selenium that referenced this pull request Aug 13, 2020
It errors when an Options instace with profile is passed to Driver.new in 'capabilities' key
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.

2 participants