selenium.webdriver.common.bidi.emulation

Classes

Emulation(conn)

BiDi implementation of the emulation module.

GeolocationCoordinates(latitude, longitude)

Represents geolocation coordinates.

GeolocationPositionError([type])

Represents a geolocation position error.

ScreenOrientation(natural, type)

Represents screen orientation configuration.

ScreenOrientationNatural(value)

Natural screen orientation.

ScreenOrientationType(value)

Screen orientation type.

class selenium.webdriver.common.bidi.emulation.ScreenOrientationNatural(value)[source]

Natural screen orientation.

PORTRAIT = 'portrait'
LANDSCAPE = 'landscape'
class selenium.webdriver.common.bidi.emulation.ScreenOrientationType(value)[source]

Screen orientation type.

PORTRAIT_PRIMARY = 'portrait-primary'
PORTRAIT_SECONDARY = 'portrait-secondary'
LANDSCAPE_PRIMARY = 'landscape-primary'
LANDSCAPE_SECONDARY = 'landscape-secondary'
class selenium.webdriver.common.bidi.emulation.ScreenOrientation(natural: ScreenOrientationNatural | str, type: ScreenOrientationType | str)[source]

Represents screen orientation configuration.

Initialize ScreenOrientation.

Args:

natural: Natural screen orientation (“portrait” or “landscape”). type: Screen orientation type (“portrait-primary”, “portrait-secondary”,

“landscape-primary”, or “landscape-secondary”).

Raises:

ValueError: If natural or type values are invalid.

to_dict() dict[str, str][source]
class selenium.webdriver.common.bidi.emulation.GeolocationCoordinates(latitude: float, longitude: float, accuracy: float = 1.0, altitude: float | None = None, altitude_accuracy: float | None = None, heading: float | None = None, speed: float | None = None)[source]

Represents geolocation coordinates.

Initialize GeolocationCoordinates.

Args:

latitude: Latitude coordinate (-90.0 to 90.0). longitude: Longitude coordinate (-180.0 to 180.0). accuracy: Accuracy in meters (>= 0.0), defaults to 1.0. altitude: Altitude in meters or None, defaults to None. altitude_accuracy: Altitude accuracy in meters (>= 0.0) or None, defaults to None. heading: Heading in degrees (0.0 to 360.0) or None, defaults to None. speed: Speed in meters per second (>= 0.0) or None, defaults to None.

Raises:

ValueError: If coordinates are out of valid range or if altitude_accuracy is provided without altitude.

property latitude
property longitude
property accuracy
property altitude
property altitude_accuracy
property heading
property speed
to_dict() dict[str, float | None][source]
class selenium.webdriver.common.bidi.emulation.GeolocationPositionError(type: str = 'positionUnavailable')[source]

Represents a geolocation position error.

TYPE_POSITION_UNAVAILABLE = 'positionUnavailable'
to_dict() dict[str, str][source]
class selenium.webdriver.common.bidi.emulation.Emulation(conn)[source]

BiDi implementation of the emulation module.

set_geolocation_override(coordinates: GeolocationCoordinates | None = None, error: GeolocationPositionError | None = None, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set geolocation override for the given contexts or user contexts.

Args:

coordinates: Geolocation coordinates to emulate, or None. error: Geolocation error to emulate, or None. contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both coordinates and error are provided, or if both contexts

and user_contexts are provided, or if neither contexts nor user_contexts are provided.

set_timezone_override(timezone: str | None = None, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set timezone override for the given contexts or user contexts.

Args:
timezone: Timezone identifier (IANA timezone name or offset string like ‘+01:00’),

or None to clear the override.

contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both contexts and user_contexts are provided, or if neither

contexts nor user_contexts are provided.

set_locale_override(locale: str | None = None, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set locale override for the given contexts or user contexts.

Args:

locale: Locale string as per BCP 47, or None to clear override. contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both contexts and user_contexts are provided, or if neither

contexts nor user_contexts are provided, or if locale is invalid.

set_scripting_enabled(enabled: bool | None = False, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set scripting enabled override for the given contexts or user contexts.

Args:
enabled: False to disable scripting, None to clear the override.

Note: Only emulation of disabled JavaScript is supported.

contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both contexts and user_contexts are provided, or if neither

contexts nor user_contexts are provided, or if enabled is True.

set_screen_orientation_override(screen_orientation: ScreenOrientation | None = None, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set screen orientation override for the given contexts or user contexts.

Args:

screen_orientation: ScreenOrientation object to emulate, or None to clear the override. contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both contexts and user_contexts are provided, or if neither

contexts nor user_contexts are provided.

set_user_agent_override(user_agent: str | None = None, contexts: list[str] | None = None, user_contexts: list[str] | None = None) None[source]

Set user agent override for the given contexts or user contexts.

Args:

user_agent: User agent string to emulate, or None to clear the override. contexts: List of browsing context IDs to apply the override to. user_contexts: List of user context IDs to apply the override to.

Raises:
ValueError: If both contexts and user_contexts are provided, or if neither

contexts nor user_contexts are provided.