File tree Expand file tree Collapse file tree 2 files changed +15
-14
lines changed
py/selenium/webdriver/common/bidi Expand file tree Collapse file tree 2 files changed +15
-14
lines changed Original file line number Diff line number Diff line change 1616# under the License.
1717
1818
19- from typing import Any , Dict , Optional
19+ from typing import Any , Optional
2020
2121from selenium .webdriver .common .bidi .common import command_builder
2222from selenium .webdriver .common .bidi .session import UserPromptHandler
@@ -204,7 +204,7 @@ def create_user_context(
204204 -------
205205 str: The ID of the created user context.
206206 """
207- params : Dict [str , Any ] = {}
207+ params : dict [str , Any ] = {}
208208
209209 if accept_insecure_certs is not None :
210210 params ["acceptInsecureCerts" ] = accept_insecure_certs
Original file line number Diff line number Diff line change @@ -84,19 +84,20 @@ def to_dict(self) -> Dict[str, str]:
8484 -------
8585 Dict[str, str]: Dictionary representation suitable for BiDi protocol
8686 """
87+ field_mapping = {
88+ "alert" : "alert" ,
89+ "before_unload" : "beforeUnload" ,
90+ "confirm" : "confirm" ,
91+ "default" : "default" ,
92+ "file" : "file" ,
93+ "prompt" : "prompt" ,
94+ }
95+
8796 result = {}
88- if self .alert is not None :
89- result ["alert" ] = self .alert
90- if self .before_unload is not None :
91- result ["beforeUnload" ] = self .before_unload
92- if self .confirm is not None :
93- result ["confirm" ] = self .confirm
94- if self .default is not None :
95- result ["default" ] = self .default
96- if self .file is not None :
97- result ["file" ] = self .file
98- if self .prompt is not None :
99- result ["prompt" ] = self .prompt
97+ for attr_name , dict_key in field_mapping .items ():
98+ value = getattr (self , attr_name )
99+ if value is not None :
100+ result [dict_key ] = value
100101 return result
101102
102103
You can’t perform that action at this time.
0 commit comments