File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
lib/selenium/webdriver/common
spec/unit/selenium/webdriver/chrome Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,20 @@ def w3c?(key)
131
131
132
132
def process_w3c_options ( options )
133
133
w3c_options = options . select { |key , val | w3c? ( key ) && !val . nil? }
134
- w3c_options [ :unhandled_prompt_behavior ] &&= w3c_options [ :unhandled_prompt_behavior ] &.to_s &.tr ( '_' , ' ' )
134
+ w3c_options [ :unhandled_prompt_behavior ] &&=
135
+ process_unhandled_prompt_behavior_value ( w3c_options [ :unhandled_prompt_behavior ] )
135
136
options . delete_if { |key , _val | w3c? ( key ) }
136
137
w3c_options
137
138
end
138
139
140
+ def process_unhandled_prompt_behavior_value ( value )
141
+ if value . is_a? ( Hash )
142
+ value . transform_values { |v | process_unhandled_prompt_behavior_value ( v ) }
143
+ else
144
+ value &.to_s &.tr ( '_' , ' ' )
145
+ end
146
+ end
147
+
139
148
def process_browser_options ( _browser_options )
140
149
nil
141
150
end
Original file line number Diff line number Diff line change @@ -267,6 +267,26 @@ module Chrome
267
267
{ 'args' => [ "--user-data-dir=#{ directory } " ] } )
268
268
end
269
269
270
+ it 'processes unhandled_prompt_behavior hash values' do
271
+ opts = described_class . new ( unhandled_prompt_behavior : {
272
+ alert : :accept_and_notify ,
273
+ confirm : 'dismiss_and_notify' ,
274
+ prompt : :ignore ,
275
+ before_unload : 'accept' ,
276
+ default : :dismiss
277
+ } )
278
+
279
+ expect ( opts . as_json ) . to eq ( 'browserName' => 'chrome' ,
280
+ 'unhandledPromptBehavior' => {
281
+ 'alert' => 'accept and notify' ,
282
+ 'confirm' => 'dismiss and notify' ,
283
+ 'prompt' => 'ignore' ,
284
+ 'beforeUnload' => 'accept' ,
285
+ 'default' => 'dismiss'
286
+ } ,
287
+ 'goog:chromeOptions' => { } )
288
+ end
289
+
270
290
it 'returns a JSON hash' do
271
291
allow ( File ) . to receive ( :file? ) . and_return ( true )
272
292
allow_any_instance_of ( described_class )
You can’t perform that action at this time.
0 commit comments