Skip to content

Commit 178b07e

Browse files
artplan1p0deje
authored andcommitted
Fixes empty options merge
1 parent d006b4c commit 178b07e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

rb/lib/selenium/webdriver/chrome/driver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def create_capabilities(opts)
103103
end
104104

105105
options = options.as_json
106-
caps.merge!(options) unless options.empty?
106+
caps.merge!(options) unless options[Options::KEY].empty?
107107

108108
caps[:proxy] = opts.delete(:proxy) if opts.key?(:proxy)
109109
caps[:proxy] ||= opts.delete('proxy') if opts.key?('proxy')

rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ module Chrome
5454
it 'does not set the chrome.detach capability by default' do
5555
Driver.new(http_client: http)
5656

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

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

113+
it 'does not merge empty options' do
114+
custom_caps = Remote::Capabilities.new('goog:chromeOptions' => {args: %w[foo bar]})
115+
116+
expect(http).to receive(:call) do |_, _, payload|
117+
expect(payload[:desiredCapabilities]['goog:chromeOptions'][:args]).to eq(%w[foo bar])
118+
resp
119+
end
120+
121+
Driver.new(http_client: http, desired_capabilities: custom_caps)
122+
end
123+
114124
it 'handshakes protocol' do
115125
expect(Remote::Bridge).to receive(:handshake)
116126
Driver.new(http_client: http)

0 commit comments

Comments
 (0)