Skip to content

Commit 5eec4b8

Browse files
committed
Minor fixes
1 parent e75da48 commit 5eec4b8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

py/selenium/webdriver/common/bidi/browsing_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def from_json(cls, json: dict) -> "BrowsingContextInfo":
110110
children = None
111111
raw_children = json.get("children")
112112
if raw_children is not None and isinstance(raw_children, list):
113-
children = [BrowsingContextInfo.from_json(child) for child in raw_children]
113+
children = [BrowsingContextInfo.from_json(child) for child in raw_children if isinstance(child, dict)]
114114

115115
return cls(
116116
context=str(json.get("context", "")),
@@ -714,7 +714,8 @@ def remove_event_handler(self, event: str, callback_id: int) -> None:
714714
event_obj = BrowsingContextEvent(event_name)
715715

716716
self.conn.remove_callback(event_obj, callback_id)
717-
self.subscriptions[event_name].remove(callback_id)
717+
if event_name in self.subscriptions and callback_id in self.subscriptions[event_name]:
718+
self.subscriptions[event_name].remove(callback_id)
718719
if len(self.subscriptions[event_name]) == 0:
719720
params = {"events": [event_name]}
720721
session = Session(self.conn)

0 commit comments

Comments
 (0)