Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions py/private/bidi_enhancements_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,20 @@ def continue_request(self, **kwargs):
params.update(kwargs)
self._conn.execute(_cb("network.continueRequest", params))''',
],
# Override auth_required to use raw dict so _auth_callback receives all
# fields (including "request") from the BiDi event params. The
# generated AuthRequiredParameters dataclass only contains "response",
# losing the "request" field that holds the request ID required to call
# network.continueWithAuth. extra_events entries appear last in the
# EVENT_CONFIGS dict literal, so this duplicate key overrides the
# CDDL-generated entry.
# Add before_request event (maps to network.beforeRequestSent)
"extra_events": [
{
"event_key": "auth_required",
"bidi_event": "network.authRequired",
"event_class": "dict",
},
{
"event_key": "before_request",
"bidi_event": "network.beforeRequestSent",
Expand Down
11 changes: 8 additions & 3 deletions py/selenium/webdriver/remote/websocket_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import dataclasses
import json
import logging
import threading
from ssl import CERT_NONE
from threading import Thread
from time import sleep
Expand Down Expand Up @@ -93,6 +94,7 @@ def __init__(self, url, timeout, interval):
self.callbacks = {}
self.session_id = None
self._id = 0
self._id_lock = threading.Lock()
self._messages = {}
self._started = False

Expand All @@ -106,18 +108,21 @@ def close(self):
self._ws = None

def execute(self, command):
self._id += 1
with self._id_lock:
self._id += 1
current_id = self._id
payload = self._serialize_command(command)
payload["id"] = self._id
payload["id"] = current_id
if self.session_id:
payload["sessionId"] = self.session_id

data = json.dumps(payload, cls=_BiDiEncoder)
logger.debug(f"-> {data}"[: self._max_log_message_size])
self._ws.send(data)

current_id = self._id
self._wait_until(lambda: current_id in self._messages)
if current_id not in self._messages:
Comment thread
AutomatedTester marked this conversation as resolved.
raise WebDriverException(f"Timed out waiting for response to BiDi command {current_id}")
response = self._messages.pop(current_id)
Comment thread
AutomatedTester marked this conversation as resolved.

if "error" in response:
Expand Down
Loading