Skip to content

Commit

Permalink
Fixes empty options merge
Browse files Browse the repository at this point in the history
  • Loading branch information
artplan1 authored and p0deje committed Jul 1, 2018
1 parent d006b4c commit 178b07e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_capabilities(opts)
end

options = options.as_json
caps.merge!(options) unless options.empty?
caps.merge!(options) unless options[Options::KEY].empty?

caps[:proxy] = opts.delete(:proxy) if opts.key?(:proxy)
caps[:proxy] ||= opts.delete('proxy') if opts.key?('proxy')
Expand Down
12 changes: 11 additions & 1 deletion rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ module Chrome
it 'does not set the chrome.detach capability by default' do
Driver.new(http_client: http)

expect(caps['goog:chromeOptions']).to eq({})
expect(caps['chrome.detach']).to be nil
end

Expand Down Expand Up @@ -111,6 +110,17 @@ module Chrome
Driver.new(http_client: http, desired_capabilities: custom_caps, args: %w[baz])
end

it 'does not merge empty options' do
custom_caps = Remote::Capabilities.new('goog:chromeOptions' => {args: %w[foo bar]})

expect(http).to receive(:call) do |_, _, payload|
expect(payload[:desiredCapabilities]['goog:chromeOptions'][:args]).to eq(%w[foo bar])
resp
end

Driver.new(http_client: http, desired_capabilities: custom_caps)
end

it 'handshakes protocol' do
expect(Remote::Bridge).to receive(:handshake)
Driver.new(http_client: http)
Expand Down

0 comments on commit 178b07e

Please sign in to comment.