Skip to content

Commit b05e2f8

Browse files
committed
Use new ChromeOptions class in specs
1 parent 89b7ba0 commit b05e2f8

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ def create_capabilities(opts)
109109
end
110110
end
111111

112-
caps['chromeOptions'] = options.as_json
112+
options = options.as_json
113+
caps[:chrome_options] = options unless options.empty?
113114

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

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ def create_chrome_driver(opt = {})
247247
server = ENV['CHROMEDRIVER'] || ENV['chrome_server']
248248
WebDriver::Chrome.driver_path = server if server
249249

250-
opt[:args] ||= ENV['TRAVIS'] ? ['--no-sandbox'] : []
250+
options = WebDriver::Chrome::Options.new
251+
options.add_argument('--no-sandbox') if ENV['TRAVIS']
252+
opt[:options] = options
251253

252254
WebDriver::Driver.for :chrome, opt
253255
end

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
module Selenium
2323
module WebDriver
2424
module Chrome
25-
describe Driver do
25+
fdescribe Driver do
2626
let(:resp) { {'sessionId' => 'foo', 'value' => Remote::Capabilities.chrome.as_json} }
2727
let(:service) { instance_double(Service, start: true, uri: 'http://example.com') }
2828
let(:caps) { Remote::Capabilities.new }
@@ -37,7 +37,7 @@ module Chrome
3737
it 'sets the args capability' do
3838
Driver.new(http_client: http, args: %w[--foo=bar])
3939

40-
expect(caps[:chrome_options]['args']).to eq(%w[--foo=bar])
40+
expect(caps[:chrome_options][:args]).to eq(%w[--foo=bar])
4141
end
4242

4343
it 'sets the proxy capabilitiy' do
@@ -57,13 +57,13 @@ module Chrome
5757
it 'sets the prefs capability' do
5858
Driver.new(http_client: http, prefs: {foo: 'bar'})
5959

60-
expect(caps[:chrome_options]['prefs']).to eq(foo: 'bar')
60+
expect(caps[:chrome_options][:prefs]).to eq(foo: 'bar')
6161
end
6262

6363
it 'lets the user override chrome.detach' do
6464
Driver.new(http_client: http, detach: true)
6565

66-
expect(caps[:chrome_options]['detach']).to be true
66+
expect(caps[:chrome_options][:detach]).to be true
6767
end
6868

6969
it 'raises an ArgumentError if args is not an Array' do
@@ -79,8 +79,8 @@ module Chrome
7979
Driver.new(http_client: http, profile: profile)
8080

8181
profile_data = profile.as_json
82-
expect(caps[:chrome_options]['args'].first).to include(profile_data[:directory])
83-
expect(caps[:chrome_options]['extensions']).to eq(profile_data[:extensions])
82+
expect(caps[:chrome_options][:args].first).to include(profile_data[:directory])
83+
expect(caps[:chrome_options][:extensions]).to eq(profile_data[:extensions])
8484
end
8585

8686
it 'takes desired capabilities' do
@@ -100,7 +100,7 @@ module Chrome
100100
custom_caps[:chrome_options] = {'args' => %w[foo bar]}
101101

102102
expect(http).to receive(:call) do |_, _, payload|
103-
expect(payload[:desiredCapabilities][:chrome_options]['args']).to eq(['baz'])
103+
expect(payload[:desiredCapabilities][:chrome_options][:args]).to eq(['baz'])
104104
resp
105105
end
106106

0 commit comments

Comments
 (0)