selenium.webdriver.common.bidi.script

Classes

EvaluateResult(type, realm[, result, ...])

Represents the result of script evaluation.

RealmCreated(realm_info)

Represents a realm created event.

RealmDestroyed(realm)

Represents a realm destroyed event.

RealmInfo(realm, origin, type[, context, ...])

Represents information about a realm.

RealmType()

Represents the possible realm types.

ResultOwnership()

Represents the possible result ownership types.

Script(conn[, driver])

BiDi implementation of the script module.

ScriptMessage(channel, data, source)

Represents a script message event.

Source(realm[, context])

Represents the source of a script message.

class selenium.webdriver.common.bidi.script.ResultOwnership[source]

Represents the possible result ownership types.

NONE = 'none'
ROOT = 'root'
class selenium.webdriver.common.bidi.script.RealmType[source]

Represents the possible realm types.

WINDOW = 'window'
DEDICATED_WORKER = 'dedicated-worker'
SHARED_WORKER = 'shared-worker'
SERVICE_WORKER = 'service-worker'
WORKER = 'worker'
PAINT_WORKLET = 'paint-worklet'
AUDIO_WORKLET = 'audio-worklet'
WORKLET = 'worklet'
class selenium.webdriver.common.bidi.script.RealmInfo(realm: str, origin: str, type: str, context: str | None = None, sandbox: str | None = None)[source]

Represents information about a realm.

realm: str
origin: str
type: str
context: str | None = None
sandbox: str | None = None
classmethod from_json(json: dict[str, Any]) RealmInfo[source]

Creates a RealmInfo instance from a dictionary.

Parameters:

json: A dictionary containing the realm information.

Returns:

RealmInfo: A new instance of RealmInfo.

class selenium.webdriver.common.bidi.script.Source(realm: str, context: str | None = None)[source]

Represents the source of a script message.

realm: str
context: str | None = None
classmethod from_json(json: dict[str, Any]) Source[source]

Creates a Source instance from a dictionary.

Parameters:

json: A dictionary containing the source information.

Returns:

Source: A new instance of Source.

class selenium.webdriver.common.bidi.script.EvaluateResult(type: str, realm: str, result: dict | None = None, exception_details: dict | None = None)[source]

Represents the result of script evaluation.

type: str
realm: str
result: dict | None = None
exception_details: dict | None = None
classmethod from_json(json: dict[str, Any]) EvaluateResult[source]

Creates an EvaluateResult instance from a dictionary.

Parameters:

json: A dictionary containing the evaluation result.

Returns:

EvaluateResult: A new instance of EvaluateResult.

class selenium.webdriver.common.bidi.script.ScriptMessage(channel: str, data: dict, source: Source)[source]

Represents a script message event.

event_class = 'script.message'
classmethod from_json(json: dict[str, Any]) ScriptMessage[source]

Creates a ScriptMessage instance from a dictionary.

Parameters:

json: A dictionary containing the script message.

Returns:

ScriptMessage: A new instance of ScriptMessage.

class selenium.webdriver.common.bidi.script.RealmCreated(realm_info: RealmInfo)[source]

Represents a realm created event.

event_class = 'script.realmCreated'
classmethod from_json(json: dict[str, Any]) RealmCreated[source]

Creates a RealmCreated instance from a dictionary.

Parameters:

json: A dictionary containing the realm created event.

Returns:

RealmCreated: A new instance of RealmCreated.

class selenium.webdriver.common.bidi.script.RealmDestroyed(realm: str)[source]

Represents a realm destroyed event.

event_class = 'script.realmDestroyed'
classmethod from_json(json: dict[str, Any]) RealmDestroyed[source]

Creates a RealmDestroyed instance from a dictionary.

Parameters:

json: A dictionary containing the realm destroyed event.

Returns:

RealmDestroyed: A new instance of RealmDestroyed.

class selenium.webdriver.common.bidi.script.Script(conn, driver=None)[source]

BiDi implementation of the script module.

EVENTS = {'message': 'script.message', 'realm_created': 'script.realmCreated', 'realm_destroyed': 'script.realmDestroyed'}
add_console_message_handler(handler)[source]
add_javascript_error_handler(handler)[source]
remove_console_message_handler(id)[source]
remove_javascript_error_handler(id)
pin(script: str) str[source]

Pins a script to the current browsing context.

Parameters:

script: The script to pin.

Returns:

str: The ID of the pinned script.

unpin(script_id: str) None[source]

Unpins a script from the current browsing context.

Parameters:

script_id: The ID of the pinned script to unpin.

execute(script: str, *args) dict[source]

Executes a script in the current browsing context.

Parameters:

script: The script function to execute. *args: Arguments to pass to the script function.

Returns:

dict: The result value from the script execution.

Raises:

WebDriverException: If the script execution fails.