Skip to content

Commit e6f53e8

Browse files
committed
Fix keyword arguments warnings in Ruby 2.7
Passing Hash to the method accepting **kwargs is deprecated in Ruby 2.7. https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0 Fixes #8315.
1 parent af6c1fd commit e6f53e8

12 files changed

Lines changed: 32 additions & 32 deletions

File tree

rb/lib/selenium/webdriver/chrome/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Options < WebDriver::Options
7575
#
7676

7777
def initialize(profile: nil, encoded_extensions: nil, **opts)
78-
super(opts)
78+
super(**opts)
7979

8080
@profile = profile
8181
@options[:encoded_extensions] = encoded_extensions if encoded_extensions

rb/lib/selenium/webdriver/common/driver.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ class << self
4343
def for(browser, opts = {})
4444
case browser
4545
when :chrome
46-
Chrome::Driver.new(opts)
46+
Chrome::Driver.new(**opts)
4747
when :internet_explorer, :ie
48-
IE::Driver.new(opts)
48+
IE::Driver.new(**opts)
4949
when :safari
50-
Safari::Driver.new(opts)
50+
Safari::Driver.new(**opts)
5151
when :firefox, :ff
52-
Firefox::Driver.new(opts)
52+
Firefox::Driver.new(**opts)
5353
when :edge
54-
Edge::Driver.new(opts)
54+
Edge::Driver.new(**opts)
5555
when :edge_chrome
56-
EdgeChrome::Driver.new(opts)
56+
EdgeChrome::Driver.new(**opts)
5757
when :edge_html
58-
EdgeHtml::Driver.new(opts)
58+
EdgeHtml::Driver.new(**opts)
5959
when :remote
60-
Remote::Driver.new(opts)
60+
Remote::Driver.new(**opts)
6161
else
6262
raise ArgumentError, "unknown driver: #{browser.inspect}"
6363
end
@@ -73,7 +73,7 @@ def for(browser, opts = {})
7373

7474
def initialize(bridge: nil, listener: nil, **opts)
7575
@service = nil
76-
bridge ||= create_bridge(opts)
76+
bridge ||= create_bridge(**opts)
7777
@bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
7878
end
7979

@@ -322,7 +322,7 @@ def create_bridge(**opts)
322322
bridge_opts = {http_client: opts.delete(:http_client), url: opts.delete(:url)}
323323
raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
324324

325-
bridge = (respond_to?(:bridge_class) ? bridge_class : Remote::Bridge).new(bridge_opts)
325+
bridge = (respond_to?(:bridge_class) ? bridge_class : Remote::Bridge).new(**bridge_opts)
326326

327327
bridge.create_session(capabilities)
328328
bridge

rb/lib/selenium/webdriver/edge_html/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Options < WebDriver::Options
5353
#
5454

5555
def initialize(**opts)
56-
super
56+
super(**opts)
5757
@options[:extensions]&.each(&method(:validate_extension))
5858
end
5959

rb/lib/selenium/webdriver/firefox/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Options < WebDriver::Options
5858
#
5959

6060
def initialize(log_level: nil, **opts)
61-
super(opts)
61+
super(**opts)
6262

6363
@options[:log] ||= {level: log_level} if log_level
6464
process_profile(@options[:profile]) if @options.key?(:profile)

rb/lib/selenium/webdriver/ie/options.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ class Options < WebDriver::Options
8686
# @option opts [Boolean] validate_cookie_document_type
8787
#
8888

89-
def initialize(args: nil, **opts)
90-
super(opts)
89+
def initialize(**opts)
90+
@args = (opts.delete(:args) || []).to_set
91+
super(**opts)
9192

92-
@args = (args || []).to_set
9393
@options[:native_events] = true if @options[:native_events].nil?
9494
end
9595

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def quit_driver
3434
end
3535

3636
def create_driver!(**opts, &block)
37-
GlobalTestEnv.create_driver!(opts, &block)
37+
GlobalTestEnv.create_driver!(**opts, &block)
3838
end
3939

4040
def ensure_single_window

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def expect_request(body: nil, endpoint: nil)
116116
expect_request(body: {capabilities: {firstMatch: ["browserName": "chrome", "goog:chromeOptions": opts]}})
117117

118118
expect {
119-
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
119+
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
120120
}.not_to raise_exception
121121
end
122122

@@ -129,7 +129,7 @@ def expect_request(body: nil, endpoint: nil)
129129

130130
expect {
131131
expect {
132-
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
132+
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
133133
}.to have_deprecated(%i[browser_options desired_capabilities])
134134
}.not_to raise_exception
135135
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def expect_request(body: nil, endpoint: nil)
122122
"ms:startPage": "http://selenium.dev"]}})
123123

124124
expect {
125-
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
125+
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
126126
}.not_to raise_exception
127127
end
128128

@@ -136,7 +136,7 @@ def expect_request(body: nil, endpoint: nil)
136136

137137
expect {
138138
expect {
139-
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
139+
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
140140
}.to have_deprecated(%i[browser_options desired_capabilities])
141141
}.not_to raise_exception
142142
end
@@ -215,7 +215,7 @@ def as_json(*)
215215
expect_request(body: {capabilities: {firstMatch: [browserName: "MicrosoftEdge",
216216
'ms:startPage': 'http://selenium.dev']}})
217217

218-
expect { Driver.new(capabilities: [Options.new(browser_opts)]) }.not_to raise_exception
218+
expect { Driver.new(capabilities: [Options.new(**browser_opts)]) }.not_to raise_exception
219219
end
220220

221221
it 'with Capabilities instance' do

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def expect_request(body: nil, endpoint: nil)
116116
expect_request(body: {capabilities: {firstMatch: ["browserName": "firefox", "moz:firefoxOptions": opts]}})
117117

118118
expect {
119-
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
119+
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
120120
}.not_to raise_exception
121121
end
122122

@@ -129,7 +129,7 @@ def expect_request(body: nil, endpoint: nil)
129129

130130
expect {
131131
expect {
132-
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
132+
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
133133
}.to have_deprecated(%i[browser_options desired_capabilities])
134134
}.not_to raise_exception
135135
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def expect_request(body: nil, endpoint: nil)
128128
"ie.browserCommandLineSwitches": "-f"}]}})
129129

130130
expect {
131-
expect { Driver.new(options: Options.new(opts)) }.to have_deprecated(:browser_options)
131+
expect { Driver.new(options: Options.new(**opts)) }.to have_deprecated(:browser_options)
132132
}.not_to raise_exception
133133
end
134134

@@ -143,7 +143,7 @@ def expect_request(body: nil, endpoint: nil)
143143

144144
expect {
145145
expect {
146-
Driver.new(options: Options.new(browser_opts), desired_capabilities: caps)
146+
Driver.new(options: Options.new(**browser_opts), desired_capabilities: caps)
147147
}.to have_deprecated(%i[browser_options desired_capabilities])
148148
}.not_to raise_exception
149149
end
@@ -223,7 +223,7 @@ def as_json(*)
223223
'se:ieOptions': {"startPage": 'http://selenium.dev',
224224
'nativeEvents': true}]}})
225225

226-
expect { Driver.new(capabilities: [Options.new(browser_opts)]) }.not_to raise_exception
226+
expect { Driver.new(capabilities: [Options.new(**browser_opts)]) }.not_to raise_exception
227227
end
228228

229229
it 'with Capabilities instance' do

0 commit comments

Comments
 (0)