From 178b07e8d52209ead9e139a5463ed8e7dc352c7a Mon Sep 17 00:00:00 2001 From: Artem Kozaev Date: Tue, 26 Jun 2018 15:24:15 +0300 Subject: [PATCH] Fixes empty options merge --- rb/lib/selenium/webdriver/chrome/driver.rb | 2 +- .../unit/selenium/webdriver/chrome/driver_spec.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rb/lib/selenium/webdriver/chrome/driver.rb b/rb/lib/selenium/webdriver/chrome/driver.rb index 89ae71df092be..836e97f482163 100644 --- a/rb/lib/selenium/webdriver/chrome/driver.rb +++ b/rb/lib/selenium/webdriver/chrome/driver.rb @@ -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') diff --git a/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb b/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb index 0196e4cf9973f..1aa2b27b2650c 100644 --- a/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb +++ b/rb/spec/unit/selenium/webdriver/chrome/driver_spec.rb @@ -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 @@ -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)