selenium.webdriver.common.bidi.network

Classes

Network(conn)

NetworkEvent(event_class, **kwargs)

Represents a network event.

Request(network, request_id[, body_size, ...])

Represents an intercepted network request.

class selenium.webdriver.common.bidi.network.NetworkEvent(event_class: str, **kwargs: Any)[source]

Represents a network event.

classmethod from_json(json: dict[str, Any]) NetworkEvent[source]
class selenium.webdriver.common.bidi.network.Network(conn: WebSocketConnection)[source]
EVENTS = {'auth_required': 'network.authRequired', 'before_request': 'network.beforeRequestSent', 'continue_auth': 'network.continueWithAuth', 'continue_request': 'network.continueRequest', 'fetch_error': 'network.fetchError', 'response_completed': 'network.responseCompleted', 'response_started': 'network.responseStarted'}
PHASES = {'auth_required': 'authRequired', 'before_request': 'beforeRequestSent', 'response_started': 'responseStarted'}
add_request_handler(event: str, callback: Callable[[Request], Any], url_patterns: list[Any] | None = None, contexts: list[str] | None = None) int[source]

Add a request handler to the network.

Args:

event: The event to subscribe to. callback: The callback function to execute on request interception.

Takes Request object as argument.

url_patterns: A list of URL patterns to intercept. Default is None. contexts: A list of contexts to intercept. Default is None.

Returns:

int: callback id

remove_request_handler(event: str, callback_id: int) None[source]

Remove a request handler from the network.

Args:

event: The event to unsubscribe from. callback_id: The callback id to remove.

clear_request_handlers() None[source]

Clear all request handlers from the network.

add_auth_handler(username: str, password: str) int[source]

Add an authentication handler to the network.

Args:

username: The username to authenticate with. password: The password to authenticate with.

Returns:

int: callback id

remove_auth_handler(callback_id: int) None[source]

Remove an authentication handler from the network.

Args:

callback_id: The callback id to remove.

class selenium.webdriver.common.bidi.network.Request(network: Network, request_id: Any, body_size: int | None = None, cookies: Any | None = None, resource_type: str | None = None, headers: Any | None = None, headers_size: int | None = None, method: str | None = None, timings: Any | None = None, url: str | None = None)[source]

Represents an intercepted network request.

fail_request() None[source]

Fail this request.

continue_request(body: Any | None = None, method: str | None = None, headers: Any | None = None, cookies: Any | None = None, url: str | None = None) None[source]

Continue after intercepting this request.