File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
lib/selenium/webdriver/common
spec/unit/selenium/webdriver/chrome Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,19 @@ def w3c?(key)
131131
132132 def process_w3c_options ( options )
133133 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 ] &&= process_unhandled_prompt_behavior_value ( w3c_options [ :unhandled_prompt_behavior ] )
135135 options . delete_if { |key , _val | w3c? ( key ) }
136136 w3c_options
137137 end
138138
139+ def process_unhandled_prompt_behavior_value ( value )
140+ if value . is_a? ( Hash )
141+ value . transform_values { |v | process_unhandled_prompt_behavior_value ( v ) }
142+ else
143+ value &.to_s &.tr ( '_' , ' ' )
144+ end
145+ end
146+
139147 def process_browser_options ( _browser_options )
140148 nil
141149 end
Original file line number Diff line number Diff line change @@ -267,6 +267,26 @@ module Chrome
267267 { 'args' => [ "--user-data-dir=#{ directory } " ] } )
268268 end
269269
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+
270290 it 'returns a JSON hash' do
271291 allow ( File ) . to receive ( :file? ) . and_return ( true )
272292 allow_any_instance_of ( described_class )
You can’t perform that action at this time.
0 commit comments