Skip to content

Commit

Permalink
Ruby - fix Chrome::Options.process_browser_options (#8410)
Browse files Browse the repository at this point in the history
It errors when an Options instace with profile is passed to Driver.new in 'capabilities' key
  • Loading branch information
masakazutakewaka authored Jun 11, 2020
1 parent 5ccaebd commit 6f36f8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def add_emulation(**opts)
def process_browser_options(browser_options)
options = browser_options[KEY]
options['binary'] ||= binary_path if binary_path
(options['args'] || []) << "--user-data-dir=#{@profile[:directory]}" if @profile
(options['args'] || []) << "--user-data-dir=#{@profile.directory}" if @profile
merge_extensions(options)
end

Expand Down
8 changes: 8 additions & 0 deletions rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ def as_json(*)
expect { Driver.new(capabilities: [options]) }.not_to raise_exception
end

it 'with Options instance with profile' do
profile = Profile.new.tap(&:layout_on_disk)
options = Options.new(profile: profile)
expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", 'goog:chromeOptions': {}]}})

expect { Driver.new(capabilities: [options]) }.not_to raise_exception
end

it 'with Capabilities instance' do
capabilities = Remote::Capabilities.new(browser_name: 'chrome', invalid: 'foobar')
expect_request(body: {capabilities: {firstMatch: [browserName: "chrome", invalid: 'foobar']}})
Expand Down

0 comments on commit 6f36f8e

Please sign in to comment.