File tree Expand file tree Collapse file tree 5 files changed +36
-27
lines changed
integration/selenium/webdriver Expand file tree Collapse file tree 5 files changed +36
-27
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,9 @@ def process_browser_options(browser_options)
227
227
228
228
options = browser_options [ self . class ::KEY ]
229
229
options [ 'binary' ] ||= binary_path if binary_path
230
+
231
+ check_w3c ( options [ :w3c ] ) if options . key? ( :w3c )
232
+
230
233
if @profile
231
234
options [ 'args' ] ||= [ ]
232
235
options [ 'args' ] << "--user-data-dir=#{ @profile . directory } "
@@ -237,6 +240,17 @@ def process_browser_options(browser_options)
237
240
options [ 'extensions' ] = @encoded_extensions + @extensions . map { |ext | encode_extension ( ext ) }
238
241
end
239
242
243
+ def check_w3c ( w3c )
244
+ if w3c
245
+ WebDriver . logger . warn ( "Setting 'w3c: true' is redundant and will no longer be allowed" , id : :w3c )
246
+ return
247
+ end
248
+
249
+ raise Error ::InvalidArgumentError ,
250
+ "Setting 'w3c: false' is not allowed.\n " \
251
+ "Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/"
252
+ end
253
+
240
254
def binary_path
241
255
Chrome . path
242
256
end
Original file line number Diff line number Diff line change @@ -49,7 +49,6 @@ def initialize(url:, http_client: nil)
49
49
#
50
50
51
51
def create_session ( capabilities )
52
- check_chrome_w3c_false ( capabilities )
53
52
response = execute ( :new_session , { } , prepare_capabilities_payload ( capabilities ) )
54
53
55
54
@session_id = response [ 'sessionId' ]
@@ -667,27 +666,6 @@ def escape_css(string)
667
666
668
667
string
669
668
end
670
-
671
- #
672
- # Checks if w3c key is set to false and raises error for the same.
673
- #
674
- def check_chrome_w3c_false ( capabilities )
675
- return unless capabilities [ 'browserName' ] == 'chrome' && capabilities . key? ( 'goog:chromeOptions' )
676
-
677
- capability = capabilities [ 'goog:chromeOptions' ]
678
- w3c = true
679
-
680
- if capability . instance_of? ( Hash )
681
- raw_w3c = capability [ 'w3c' ]
682
- w3c = raw_w3c . nil? || raw_w3c
683
- end
684
-
685
- return if w3c
686
-
687
- raise Error ::WebDriverError , "Setting 'w3c: false' is not allowed.\n " \
688
- "Please update to W3C Syntax: https://www" \
689
- ".selenium.dev/blog/2022/legacy-protocol-support/"
690
- end
691
669
end # Bridge
692
670
end # Remote
693
671
end # WebDriver
Original file line number Diff line number Diff line change @@ -39,11 +39,6 @@ module WebDriver
39
39
end
40
40
end
41
41
42
- it 'should raise error when w3c is false' , exclusive : { browser : %i[ chrome ] } do
43
- options = Selenium ::WebDriver ::Chrome ::Options . new ( w3c : false )
44
- expect { Selenium ::WebDriver . for :chrome , capabilities : options } . to raise_error ( Error ::WebDriverError )
45
- end
46
-
47
42
it 'should get driver status' do
48
43
status = driver . status
49
44
expect ( status ) . to include ( 'ready' , 'message' )
Original file line number Diff line number Diff line change @@ -247,6 +247,17 @@ module Chrome
247
247
expect ( options . as_json ) . to eq ( "browserName" => "chrome" , "goog:chromeOptions" => { } )
248
248
end
249
249
250
+ it 'should raise error when w3c is false' do
251
+ options . add_option ( :w3c , false )
252
+ expect { options . as_json } . to raise_error ( Error ::InvalidArgumentError )
253
+ end
254
+
255
+ it 'should raise error when w3c is true' do
256
+ msg = /WARN Selenium \[ :w3c\] /
257
+ options . add_option ( :w3c , true )
258
+ expect { options . as_json } . to output ( msg ) . to_stdout_from_any_process
259
+ end
260
+
250
261
it 'returns added options' do
251
262
options . add_option ( :foo , 'bar' )
252
263
options . add_option ( 'foo:bar' , { foo : 'bar' } )
Original file line number Diff line number Diff line change @@ -203,6 +203,17 @@ module Edge
203
203
expect ( options . as_json ) . to eq ( "browserName" => "MicrosoftEdge" , "ms:edgeOptions" => { } )
204
204
end
205
205
206
+ it 'should raise error when w3c is false' do
207
+ options . add_option ( :w3c , false )
208
+ expect { options . as_json } . to raise_error ( Error ::InvalidArgumentError )
209
+ end
210
+
211
+ it 'should raise error when w3c is true' do
212
+ msg = /WARN Selenium \[ :w3c\] /
213
+ options . add_option ( :w3c , true )
214
+ expect { options . as_json } . to output ( msg ) . to_stdout_from_any_process
215
+ end
216
+
206
217
it 'returns added options' do
207
218
options . add_option ( :foo , 'bar' )
208
219
options . add_option ( 'foo:bar' , { foo : 'bar' } )
You can’t perform that action at this time.
0 commit comments