emulation
DevicePosture
dataclass
Source code in zendriver/cdp/emulation.py
type_: str
instance-attribute
__init__(type_)
from_json(json)
classmethod
DisabledImageType
Bases: Enum
Enum of image types that can be disabled.
Source code in zendriver/cdp/emulation.py
AVIF = 'avif'
class-attribute
instance-attribute
JXL = 'jxl'
class-attribute
instance-attribute
WEBP = 'webp'
class-attribute
instance-attribute
from_json(json)
classmethod
DisplayFeature
dataclass
Source code in zendriver/cdp/emulation.py
mask_length: int
instance-attribute
offset: int
instance-attribute
orientation: str
instance-attribute
__init__(orientation, offset, mask_length)
from_json(json)
classmethod
MediaFeature
dataclass
Source code in zendriver/cdp/emulation.py
name: str
instance-attribute
value: str
instance-attribute
__init__(name, value)
from_json(json)
classmethod
PressureMetadata
dataclass
Source code in zendriver/cdp/emulation.py
available: typing.Optional[bool] = None
class-attribute
instance-attribute
__init__(available=None)
from_json(json)
classmethod
PressureSource
Bases: Enum
Source code in zendriver/cdp/emulation.py
CPU = 'cpu'
class-attribute
instance-attribute
from_json(json)
classmethod
PressureState
Bases: Enum
Source code in zendriver/cdp/emulation.py
CRITICAL = 'critical'
class-attribute
instance-attribute
FAIR = 'fair'
class-attribute
instance-attribute
NOMINAL = 'nominal'
class-attribute
instance-attribute
SERIOUS = 'serious'
class-attribute
instance-attribute
from_json(json)
classmethod
SafeAreaInsets
dataclass
Source code in zendriver/cdp/emulation.py
bottom: typing.Optional[int] = None
class-attribute
instance-attribute
bottom_max: typing.Optional[int] = None
class-attribute
instance-attribute
left: typing.Optional[int] = None
class-attribute
instance-attribute
left_max: typing.Optional[int] = None
class-attribute
instance-attribute
right: typing.Optional[int] = None
class-attribute
instance-attribute
right_max: typing.Optional[int] = None
class-attribute
instance-attribute
top: typing.Optional[int] = None
class-attribute
instance-attribute
top_max: typing.Optional[int] = None
class-attribute
instance-attribute
__init__(top=None, top_max=None, left=None, left_max=None, bottom=None, bottom_max=None, right=None, right_max=None)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
ScreenId
Bases: str
Source code in zendriver/cdp/emulation.py
__repr__()
from_json(json)
classmethod
ScreenInfo
dataclass
Screen information similar to the one returned by window.getScreenDetails() method, see https://w3c.github.io/window-management/#screendetailed.
Source code in zendriver/cdp/emulation.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
avail_height: int
instance-attribute
avail_left: int
instance-attribute
avail_top: int
instance-attribute
avail_width: int
instance-attribute
color_depth: int
instance-attribute
device_pixel_ratio: float
instance-attribute
height: int
instance-attribute
id_: ScreenId
instance-attribute
is_extended: bool
instance-attribute
is_internal: bool
instance-attribute
is_primary: bool
instance-attribute
label: str
instance-attribute
left: int
instance-attribute
orientation: ScreenOrientation
instance-attribute
top: int
instance-attribute
width: int
instance-attribute
__init__(left, top, width, height, avail_left, avail_top, avail_width, avail_height, device_pixel_ratio, orientation, color_depth, is_extended, is_internal, is_primary, label, id_)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
ScreenOrientation
dataclass
Screen orientation.
Source code in zendriver/cdp/emulation.py
angle: int
instance-attribute
type_: str
instance-attribute
__init__(type_, angle)
from_json(json)
classmethod
ScreenOrientationLockChanged
dataclass
EXPERIMENTAL
Fired when a page calls screen.orientation.lock() or screen.orientation.unlock() while device emulation is enabled. This allows the DevTools frontend to update the emulated device orientation accordingly.
Source code in zendriver/cdp/emulation.py
locked: bool
instance-attribute
orientation: typing.Optional[ScreenOrientation]
instance-attribute
__init__(locked, orientation)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
SensorMetadata
dataclass
Source code in zendriver/cdp/emulation.py
available: typing.Optional[bool] = None
class-attribute
instance-attribute
maximum_frequency: typing.Optional[float] = None
class-attribute
instance-attribute
minimum_frequency: typing.Optional[float] = None
class-attribute
instance-attribute
__init__(available=None, minimum_frequency=None, maximum_frequency=None)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
SensorReading
dataclass
Source code in zendriver/cdp/emulation.py
quaternion: typing.Optional[SensorReadingQuaternion] = None
class-attribute
instance-attribute
single: typing.Optional[SensorReadingSingle] = None
class-attribute
instance-attribute
xyz: typing.Optional[SensorReadingXYZ] = None
class-attribute
instance-attribute
__init__(single=None, xyz=None, quaternion=None)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
SensorReadingQuaternion
dataclass
Source code in zendriver/cdp/emulation.py
w: float
instance-attribute
x: float
instance-attribute
y: float
instance-attribute
z: float
instance-attribute
__init__(x, y, z, w)
from_json(json)
classmethod
SensorReadingSingle
dataclass
Source code in zendriver/cdp/emulation.py
value: float
instance-attribute
__init__(value)
from_json(json)
classmethod
SensorReadingXYZ
dataclass
Source code in zendriver/cdp/emulation.py
x: float
instance-attribute
y: float
instance-attribute
z: float
instance-attribute
__init__(x, y, z)
from_json(json)
classmethod
SensorType
Bases: Enum
Used to specify sensor types to emulate. See https://w3c.github.io/sensors/#automation for more information.
Source code in zendriver/cdp/emulation.py
ABSOLUTE_ORIENTATION = 'absolute-orientation'
class-attribute
instance-attribute
ACCELEROMETER = 'accelerometer'
class-attribute
instance-attribute
AMBIENT_LIGHT = 'ambient-light'
class-attribute
instance-attribute
GRAVITY = 'gravity'
class-attribute
instance-attribute
GYROSCOPE = 'gyroscope'
class-attribute
instance-attribute
LINEAR_ACCELERATION = 'linear-acceleration'
class-attribute
instance-attribute
MAGNETOMETER = 'magnetometer'
class-attribute
instance-attribute
RELATIVE_ORIENTATION = 'relative-orientation'
class-attribute
instance-attribute
from_json(json)
classmethod
UserAgentBrandVersion
dataclass
Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints
Source code in zendriver/cdp/emulation.py
brand: str
instance-attribute
version: str
instance-attribute
__init__(brand, version)
from_json(json)
classmethod
UserAgentMetadata
dataclass
Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints Missing optional values will be filled in by the target with what it would normally use.
Source code in zendriver/cdp/emulation.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
architecture: str
instance-attribute
bitness: typing.Optional[str] = None
class-attribute
instance-attribute
brands: typing.Optional[typing.List[UserAgentBrandVersion]] = None
class-attribute
instance-attribute
form_factors: typing.Optional[typing.List[str]] = None
class-attribute
instance-attribute
full_version: typing.Optional[str] = None
class-attribute
instance-attribute
full_version_list: typing.Optional[typing.List[UserAgentBrandVersion]] = None
class-attribute
instance-attribute
mobile: bool
instance-attribute
model: str
instance-attribute
platform: str
instance-attribute
platform_version: str
instance-attribute
wow64: typing.Optional[bool] = None
class-attribute
instance-attribute
__init__(platform, platform_version, architecture, model, mobile, brands=None, full_version_list=None, full_version=None, bitness=None, wow64=None, form_factors=None)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
VirtualTimeBudgetExpired
dataclass
EXPERIMENTAL
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
Source code in zendriver/cdp/emulation.py
VirtualTimePolicy
Bases: Enum
advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.
Source code in zendriver/cdp/emulation.py
ADVANCE = 'advance'
class-attribute
instance-attribute
PAUSE = 'pause'
class-attribute
instance-attribute
PAUSE_IF_NETWORK_FETCHES_PENDING = 'pauseIfNetworkFetchesPending'
class-attribute
instance-attribute
from_json(json)
classmethod
WorkAreaInsets
dataclass
Source code in zendriver/cdp/emulation.py
bottom: typing.Optional[int] = None
class-attribute
instance-attribute
left: typing.Optional[int] = None
class-attribute
instance-attribute
right: typing.Optional[int] = None
class-attribute
instance-attribute
top: typing.Optional[int] = None
class-attribute
instance-attribute
__init__(top=None, left=None, bottom=None, right=None)
from_json(json)
classmethod
Source code in zendriver/cdp/emulation.py
to_json()
Source code in zendriver/cdp/emulation.py
add_screen(left, top, width, height, work_area_insets=None, device_pixel_ratio=None, rotation=None, color_depth=None, label=None, is_internal=None)
Add a new screen to the device. Only supported in headless mode.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
int
|
Offset of the left edge of the screen in pixels. |
required |
top
|
int
|
Offset of the top edge of the screen in pixels. |
required |
width
|
int
|
The width of the screen in pixels. |
required |
height
|
int
|
The height of the screen in pixels. |
required |
work_area_insets
|
Optional[WorkAreaInsets]
|
(Optional) Specifies the screen's work area. Default is entire screen. |
None
|
device_pixel_ratio
|
Optional[float]
|
(Optional) Specifies the screen's device pixel ratio. Default is 1. |
None
|
rotation
|
Optional[int]
|
(Optional) Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0. |
None
|
color_depth
|
Optional[int]
|
(Optional) Specifies the screen's color depth in bits. Default is 24. |
None
|
label
|
Optional[str]
|
(Optional) Specifies the descriptive label for the screen. Default is none. |
None
|
is_internal
|
Optional[bool]
|
(Optional) Indicates whether the screen is internal to the device or external, attached to the device. Default is false. |
None
|
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, ScreenInfo]
|
|
Source code in zendriver/cdp/emulation.py
can_emulate()
Tells whether emulation is supported.
.. deprecated:: 1.3
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, bool]
|
True if emulation is supported. |
Source code in zendriver/cdp/emulation.py
clear_device_metrics_override()
Clears the overridden device metrics.
Source code in zendriver/cdp/emulation.py
clear_device_posture_override()
Clears a device posture override set with either setDeviceMetricsOverride() or setDevicePostureOverride() and starts using posture information from the platform again. Does nothing if no override is set.
EXPERIMENTAL
Source code in zendriver/cdp/emulation.py
clear_display_features_override()
Clears the display features override set with either setDeviceMetricsOverride() or setDisplayFeaturesOverride() and starts using display features from the platform again. Does nothing if no override is set.
EXPERIMENTAL
Source code in zendriver/cdp/emulation.py
clear_geolocation_override()
Clears the overridden Geolocation Position and Error.
Source code in zendriver/cdp/emulation.py
clear_idle_override()
Clears Idle state overrides.
get_overridden_sensor_information(type_)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
SensorType
|
|
required |
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, float]
|
|
Source code in zendriver/cdp/emulation.py
get_screen_infos()
Returns device's screen configuration. In headful mode, the physical screens configuration is returned, whereas in headless mode, a virtual headless screen configuration is provided instead.
EXPERIMENTAL
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, List[ScreenInfo]]
|
|
Source code in zendriver/cdp/emulation.py
remove_screen(screen_id)
Remove screen from the device. Only supported in headless mode.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen_id
|
ScreenId
|
|
required |
Source code in zendriver/cdp/emulation.py
reset_page_scale_factor()
Requests that page scale factor is reset to initial values.
EXPERIMENTAL
Source code in zendriver/cdp/emulation.py
set_auto_dark_mode_override(enabled=None)
Automatically render all web contents using a dark theme.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
Optional[bool]
|
(Optional) Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared. |
None
|
Source code in zendriver/cdp/emulation.py
set_automation_override(enabled)
Allows overriding the automation flag.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the override should be enabled. |
required |
Source code in zendriver/cdp/emulation.py
set_cpu_throttling_rate(rate)
Enables CPU throttling to emulate slow CPUs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). |
required |
Source code in zendriver/cdp/emulation.py
set_data_saver_override(data_saver_enabled=None)
Override the value of navigator.connection.saveData
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_saver_enabled
|
Optional[bool]
|
(Optional) Override value. Omitting the parameter disables the override. |
None
|
Source code in zendriver/cdp/emulation.py
set_default_background_color_override(color=None)
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Optional[RGBA]
|
(Optional) RGBA of the default background color. If not specified, any existing override will be cleared. |
None
|
Source code in zendriver/cdp/emulation.py
set_device_metrics_override(width, height, device_scale_factor, mobile, scale=None, screen_width=None, screen_height=None, position_x=None, position_y=None, dont_set_visible_size=None, screen_orientation=None, viewport=None, display_feature=None, device_posture=None, scrollbar_type=None, screen_orientation_lock_emulation=None)
Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. |
required |
height
|
int
|
Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. |
required |
device_scale_factor
|
float
|
Overriding device scale factor value. 0 disables the override. |
required |
mobile
|
bool
|
Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. |
required |
scale
|
Optional[float]
|
(EXPERIMENTAL) (Optional) Scale to apply to resulting view image. |
None
|
screen_width
|
Optional[int]
|
(EXPERIMENTAL) (Optional) Overriding screen width value in pixels (minimum 0, maximum 10000000). |
None
|
screen_height
|
Optional[int]
|
(EXPERIMENTAL) (Optional) Overriding screen height value in pixels (minimum 0, maximum 10000000). |
None
|
position_x
|
Optional[int]
|
(EXPERIMENTAL) (Optional) Overriding view X position on screen in pixels (minimum 0, maximum 10000000). |
None
|
position_y
|
Optional[int]
|
(EXPERIMENTAL) (Optional) Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). |
None
|
dont_set_visible_size
|
Optional[bool]
|
(EXPERIMENTAL) (Optional) Do not set visible view size, rely upon explicit setVisibleSize call. |
None
|
screen_orientation
|
Optional[ScreenOrientation]
|
(Optional) Screen orientation override. |
None
|
viewport
|
Optional[Viewport]
|
(EXPERIMENTAL) (Optional) If set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions. |
None
|
display_feature
|
Optional[DisplayFeature]
|
(DEPRECATED) (EXPERIMENTAL) (Optional) If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride. |
None
|
device_posture
|
Optional[DevicePosture]
|
(DEPRECATED) (EXPERIMENTAL) (Optional) If set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride. |
None
|
scrollbar_type
|
Optional[str]
|
(EXPERIMENTAL) (Optional) Scrollbar type. Default: |
None
|
screen_orientation_lock_emulation
|
Optional[bool]
|
(EXPERIMENTAL) (Optional) If set to true, enables screen orientation lock emulation, which intercepts screen.orientation.lock() calls from the page and reports orientation changes via screenOrientationLockChanged events. This is useful for emulating mobile device orientation lock behavior in responsive design mode. |
None
|
Source code in zendriver/cdp/emulation.py
set_device_posture_override(posture)
Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
posture
|
DevicePosture
|
|
required |
Source code in zendriver/cdp/emulation.py
set_disabled_image_types(image_types)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_types
|
List[DisabledImageType]
|
Image types to disable. |
required |
Source code in zendriver/cdp/emulation.py
set_display_features_override(features)
Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
List[DisplayFeature]
|
|
required |
Source code in zendriver/cdp/emulation.py
set_document_cookie_disabled(disabled)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disabled
|
bool
|
Whether document.coookie API should be disabled. |
required |
Source code in zendriver/cdp/emulation.py
set_emit_touch_events_for_mouse(enabled, configuration=None)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether touch emulation based on mouse input should be enabled. |
required |
configuration
|
Optional[str]
|
(Optional) Touch/gesture events configuration. Default: current platform. |
None
|
Source code in zendriver/cdp/emulation.py
set_emulated_media(media=None, features=None)
Emulates the given media type or media feature for CSS media queries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
media
|
Optional[str]
|
(Optional) Media type to emulate. Empty string disables the override. |
None
|
features
|
Optional[List[MediaFeature]]
|
(Optional) Media features to emulate. |
None
|
Source code in zendriver/cdp/emulation.py
set_emulated_os_text_scale(scale=None)
Emulates the given OS text scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale
|
Optional[float]
|
(Optional) |
None
|
Source code in zendriver/cdp/emulation.py
set_emulated_vision_deficiency(type_)
Emulates the given vision deficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
str
|
Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies. |
required |
Source code in zendriver/cdp/emulation.py
set_focus_emulation_enabled(enabled)
Enables or disables simulating a focused and active page.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether to enable to disable focus emulation. |
required |
Source code in zendriver/cdp/emulation.py
set_geolocation_override(latitude=None, longitude=None, accuracy=None, altitude=None, altitude_accuracy=None, heading=None, speed=None)
Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latitude
|
Optional[float]
|
(Optional) Mock latitude |
None
|
longitude
|
Optional[float]
|
(Optional) Mock longitude |
None
|
accuracy
|
Optional[float]
|
(Optional) Mock accuracy |
None
|
altitude
|
Optional[float]
|
(Optional) Mock altitude |
None
|
altitude_accuracy
|
Optional[float]
|
(Optional) Mock altitudeAccuracy |
None
|
heading
|
Optional[float]
|
(Optional) Mock heading |
None
|
speed
|
Optional[float]
|
(Optional) Mock speed |
None
|
Source code in zendriver/cdp/emulation.py
set_hardware_concurrency_override(hardware_concurrency)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hardware_concurrency
|
int
|
Hardware concurrency to report |
required |
Source code in zendriver/cdp/emulation.py
set_idle_override(is_user_active, is_screen_unlocked)
Overrides the Idle state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
is_user_active
|
bool
|
Mock isUserActive |
required |
is_screen_unlocked
|
bool
|
Mock isScreenUnlocked |
required |
Source code in zendriver/cdp/emulation.py
set_locale_override(locale=None)
Overrides default host system locale with the specified one.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locale
|
Optional[str]
|
(Optional) ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale. |
None
|
Source code in zendriver/cdp/emulation.py
set_navigator_overrides(platform)
Overrides value returned by the javascript navigator object.
.. deprecated:: 1.3
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
platform
|
str
|
The platform navigator.platform should return. |
required |
Source code in zendriver/cdp/emulation.py
set_page_scale_factor(page_scale_factor)
Sets a specified page scale factor.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_scale_factor
|
float
|
Page scale factor. |
required |
Source code in zendriver/cdp/emulation.py
set_pressure_data_override(source, state, own_contribution_estimate=None)
Provides a given pressure data set that will be processed and eventually be
delivered to PressureObserver users. source must have been previously
overridden by setPressureSourceOverrideEnabled.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PressureSource
|
|
required |
state
|
PressureState
|
|
required |
own_contribution_estimate
|
Optional[float]
|
(Optional) |
None
|
Source code in zendriver/cdp/emulation.py
set_pressure_source_override_enabled(enabled, source, metadata=None)
Overrides a pressure source of a given type, as used by the Compute Pressure API, so that updates to PressureObserver.observe() are provided via setPressureStateOverride instead of being retrieved from platform-provided telemetry data.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
|
required |
source
|
PressureSource
|
|
required |
metadata
|
Optional[PressureMetadata]
|
(Optional) |
None
|
Source code in zendriver/cdp/emulation.py
set_pressure_state_override(source, state)
TODO: OBSOLETE: To remove when setPressureDataOverride is merged.
Provides a given pressure state that will be processed and eventually be
delivered to PressureObserver users. source must have been previously
overridden by setPressureSourceOverrideEnabled.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
PressureSource
|
|
required |
state
|
PressureState
|
|
required |
Source code in zendriver/cdp/emulation.py
set_primary_screen(screen_id)
Set primary screen. Only supported in headless mode. Note that this changes the coordinate system origin to the top-left of the new primary screen, updating the bounds and work areas of all existing screens accordingly.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen_id
|
ScreenId
|
|
required |
Source code in zendriver/cdp/emulation.py
set_safe_area_insets_override(insets)
Overrides the values for env(safe-area-inset-) and env(safe-area-max-inset-). Unset values will cause the respective variables to be undefined, even if previously overridden.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
insets
|
SafeAreaInsets
|
|
required |
Source code in zendriver/cdp/emulation.py
set_script_execution_disabled(value)
Switches script execution in the page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
Whether script execution should be disabled in the page. |
required |
Source code in zendriver/cdp/emulation.py
set_scrollbars_hidden(hidden)
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hidden
|
bool
|
Whether scrollbars should be always hidden. |
required |
Source code in zendriver/cdp/emulation.py
set_sensor_override_enabled(enabled, type_, metadata=None)
Overrides a platform sensor of a given type. If enabled is true, calls to
Sensor.start() will use a virtual sensor as backend rather than fetching
data from a real hardware sensor. Otherwise, existing virtual
sensor-backend Sensor objects will fire an error event and new calls to
Sensor.start() will attempt to use a real sensor instead.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
|
required |
type_
|
SensorType
|
|
required |
metadata
|
Optional[SensorMetadata]
|
(Optional) |
None
|
Source code in zendriver/cdp/emulation.py
set_sensor_override_readings(type_, reading)
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
SensorType
|
|
required |
reading
|
SensorReading
|
|
required |
Source code in zendriver/cdp/emulation.py
set_small_viewport_height_difference_override(difference)
Allows overriding the difference between the small and large viewport sizes, which determine the
value of the svh and lvh unit, respectively. Only supported for top-level frames.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
difference
|
int
|
This will cause an element of size 100svh to be |
required |
Source code in zendriver/cdp/emulation.py
set_timezone_override(timezone_id)
Overrides default host system timezone with the specified one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timezone_id
|
str
|
The timezone identifier. List of supported timezones: https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt If empty, disables the override and restores default host system timezone. |
required |
Source code in zendriver/cdp/emulation.py
set_touch_emulation_enabled(enabled, max_touch_points=None)
Enables touch on platforms which do not support them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the touch event emulation should be enabled. |
required |
max_touch_points
|
Optional[int]
|
(Optional) Maximum touch points supported. Defaults to one. |
None
|
Source code in zendriver/cdp/emulation.py
set_user_agent_override(user_agent, accept_language=None, platform=None, user_agent_metadata=None)
Allows overriding user agent with the given string.
userAgentMetadata must be set for Client Hint headers to be sent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_agent
|
str
|
User agent to use. |
required |
accept_language
|
Optional[str]
|
(Optional) Browser language to emulate. |
None
|
platform
|
Optional[str]
|
(Optional) The platform navigator.platform should return. |
None
|
user_agent_metadata
|
Optional[UserAgentMetadata]
|
(EXPERIMENTAL) (Optional) To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData |
None
|
Source code in zendriver/cdp/emulation.py
set_virtual_time_policy(policy, budget=None, max_virtual_time_task_starvation_count=None, initial_virtual_time=None)
Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy. Note this supersedes any previous time budget.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
VirtualTimePolicy
|
|
required |
budget
|
Optional[float]
|
(Optional) If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent. |
None
|
max_virtual_time_task_starvation_count
|
Optional[int]
|
(Optional) If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock. |
None
|
initial_virtual_time
|
Optional[TimeSinceEpoch]
|
(Optional) If set, base::Time::Now will be overridden to initially return this value. |
None
|
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, float]
|
Absolute timestamp at which virtual time was first enabled (up time in milliseconds). |
Source code in zendriver/cdp/emulation.py
set_visible_size(width, height)
Resizes the frame/viewport of the page. Note that this does not affect the frame's container (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported on Android.
.. deprecated:: 1.3
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
Frame width (DIP). |
required |
height
|
int
|
Frame height (DIP). |
required |
Source code in zendriver/cdp/emulation.py
update_screen(screen_id, left=None, top=None, width=None, height=None, work_area_insets=None, device_pixel_ratio=None, rotation=None, color_depth=None, label=None, is_internal=None)
Updates specified screen parameters. Only supported in headless mode.
EXPERIMENTAL
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen_id
|
ScreenId
|
Target screen identifier. |
required |
left
|
Optional[int]
|
(Optional) Offset of the left edge of the screen in pixels. |
None
|
top
|
Optional[int]
|
(Optional) Offset of the top edge of the screen in pixels. |
None
|
width
|
Optional[int]
|
(Optional) The width of the screen in pixels. |
None
|
height
|
Optional[int]
|
(Optional) The height of the screen in pixels. |
None
|
work_area_insets
|
Optional[WorkAreaInsets]
|
(Optional) Specifies the screen's work area. |
None
|
device_pixel_ratio
|
Optional[float]
|
(Optional) Specifies the screen's device pixel ratio. |
None
|
rotation
|
Optional[int]
|
(Optional) Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270. |
None
|
color_depth
|
Optional[int]
|
(Optional) Specifies the screen's color depth in bits. |
None
|
label
|
Optional[str]
|
(Optional) Specifies the descriptive label for the screen. |
None
|
is_internal
|
Optional[bool]
|
(Optional) Indicates whether the screen is internal to the device or external, attached to the device. Default is false. |
None
|
Returns:
| Type | Description |
|---|---|
Generator[T_JSON_DICT, T_JSON_DICT, ScreenInfo]
|
|