Skip to content

Commit 63e1f96

Browse files
committed
apply suggestions
1 parent 65443f9 commit 63e1f96

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

py/selenium/webdriver/common/bidi/browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717

1818

19-
from typing import Any, Dict, Optional
19+
from typing import Any, Optional
2020

2121
from selenium.webdriver.common.bidi.common import command_builder
2222
from 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

py/selenium/webdriver/common/bidi/session.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)