Table of Contents

Interface IEmulation

Namespace
Selenium.WebDriver.BiDi.Cdp.Emulation
Assembly
Selenium.WebDriver.BiDi.Cdp.dll

This domain emulates different environments for the page.

public interface IEmulation

Properties

ScreenOrientationLockChanged

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.

[Experimental("BIDICDP001")]
IEventSource<ScreenOrientationLockChangedEventArgs> ScreenOrientationLockChanged { get; }

Property Value

IEventSource<ScreenOrientationLockChangedEventArgs>

Remarks

Event args (ScreenOrientationLockChangedEventArgs):

  • Locked - Whether the screen orientation is currently locked.
  • Orientation - The orientation lock type requested by the page. Only set when locked is true.

VirtualTimeBudgetExpired

Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.

[Experimental("BIDICDP001")]
IEventSource<VirtualTimeBudgetExpiredEventArgs> VirtualTimeBudgetExpired { get; }

Property Value

IEventSource<VirtualTimeBudgetExpiredEventArgs>

Methods

AddScreenAsync(long, long, long, long, WorkAreaInsets?, double?, long?, long?, string?, bool?, string?, CancellationToken)

Add a new screen to the device. Only supported in headless mode.

[Experimental("BIDICDP001")]
Task<AddScreenResult> AddScreenAsync(long left, long top, long width, long height, WorkAreaInsets? workAreaInsets = null, double? devicePixelRatio = null, long? rotation = null, long? colorDepth = null, string? label = null, bool? isInternal = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

left long

Offset of the left edge of the screen in pixels.

top long

Offset of the top edge of the screen in pixels.

width long

The width of the screen in pixels.

height long

The height of the screen in pixels.

workAreaInsets WorkAreaInsets

Specifies the screen's work area. Default is entire screen.

devicePixelRatio double?

Specifies the screen's device pixel ratio. Default is 1.

rotation long?

Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0.

colorDepth long?

Specifies the screen's color depth in bits. Default is 24.

label string

Specifies the descriptive label for the screen. Default is none.

isInternal bool?

Indicates whether the screen is internal to the device or external, attached to the device. Default is false.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<AddScreenResult>

A task representing the asynchronous operation, containing a AddScreenResult.

CanEmulateAsync(string?, CancellationToken)

Tells whether emulation is supported.

[Obsolete]
Task<CanEmulateResult> CanEmulateAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<CanEmulateResult>

A task representing the asynchronous operation, containing a CanEmulateResult.

ClearDeviceMetricsOverrideAsync(string?, CancellationToken)

Clears the overridden device metrics.

Task<ClearDeviceMetricsOverrideResult> ClearDeviceMetricsOverrideAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ClearDeviceMetricsOverrideResult>

A task representing the asynchronous operation, containing a ClearDeviceMetricsOverrideResult.

ClearDevicePostureOverrideAsync(string?, CancellationToken)

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("BIDICDP001")]
Task<ClearDevicePostureOverrideResult> ClearDevicePostureOverrideAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ClearDevicePostureOverrideResult>

A task representing the asynchronous operation, containing a ClearDevicePostureOverrideResult.

ClearDisplayFeaturesOverrideAsync(string?, CancellationToken)

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("BIDICDP001")]
Task<ClearDisplayFeaturesOverrideResult> ClearDisplayFeaturesOverrideAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ClearDisplayFeaturesOverrideResult>

A task representing the asynchronous operation, containing a ClearDisplayFeaturesOverrideResult.

ClearGeolocationOverrideAsync(string?, CancellationToken)

Clears the overridden Geolocation Position and Error.

Task<ClearGeolocationOverrideResult> ClearGeolocationOverrideAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ClearGeolocationOverrideResult>

A task representing the asynchronous operation, containing a ClearGeolocationOverrideResult.

ClearIdleOverrideAsync(string?, CancellationToken)

Clears Idle state overrides.

Task<ClearIdleOverrideResult> ClearIdleOverrideAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ClearIdleOverrideResult>

A task representing the asynchronous operation, containing a ClearIdleOverrideResult.

GetOverriddenSensorInformationAsync(SensorType, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<GetOverriddenSensorInformationResult> GetOverriddenSensorInformationAsync(SensorType type, string? session = null, CancellationToken cancellationToken = default)

Parameters

type SensorType
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<GetOverriddenSensorInformationResult>

A task representing the asynchronous operation, containing a GetOverriddenSensorInformationResult.

GetScreenInfosAsync(string?, CancellationToken)

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("BIDICDP001")]
Task<GetScreenInfosResult> GetScreenInfosAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<GetScreenInfosResult>

A task representing the asynchronous operation, containing a GetScreenInfosResult.

RemoveScreenAsync(ScreenId, string?, CancellationToken)

Remove screen from the device. Only supported in headless mode.

[Experimental("BIDICDP001")]
Task<RemoveScreenResult> RemoveScreenAsync(ScreenId screenId, string? session = null, CancellationToken cancellationToken = default)

Parameters

screenId ScreenId
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<RemoveScreenResult>

A task representing the asynchronous operation, containing a RemoveScreenResult.

ResetPageScaleFactorAsync(string?, CancellationToken)

Requests that page scale factor is reset to initial values.

[Experimental("BIDICDP001")]
Task<ResetPageScaleFactorResult> ResetPageScaleFactorAsync(string? session = null, CancellationToken cancellationToken = default)

Parameters

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<ResetPageScaleFactorResult>

A task representing the asynchronous operation, containing a ResetPageScaleFactorResult.

SetAutoDarkModeOverrideAsync(bool?, string?, CancellationToken)

Automatically render all web contents using a dark theme.

[Experimental("BIDICDP001")]
Task<SetAutoDarkModeOverrideResult> SetAutoDarkModeOverrideAsync(bool? enabled = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool?

Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetAutoDarkModeOverrideResult>

A task representing the asynchronous operation, containing a SetAutoDarkModeOverrideResult.

SetAutomationOverrideAsync(bool, string?, CancellationToken)

Allows overriding the automation flag.

[Experimental("BIDICDP001")]
Task<SetAutomationOverrideResult> SetAutomationOverrideAsync(bool enabled, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool

Whether the override should be enabled.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetAutomationOverrideResult>

A task representing the asynchronous operation, containing a SetAutomationOverrideResult.

SetCPUPerformanceOverrideAsync(string?, string?, CancellationToken)

Overrides the value of navigator.cpuPerformance

[Experimental("BIDICDP001")]
Task<SetCPUPerformanceOverrideResult> SetCPUPerformanceOverrideAsync(string? performanceTier = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

performanceTier string

Override value. Omitting the parameter disables the override.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetCPUPerformanceOverrideResult>

A task representing the asynchronous operation, containing a SetCPUPerformanceOverrideResult.

SetCPUThrottlingRateAsync(double, string?, CancellationToken)

Enables CPU throttling to emulate slow CPUs.

Task<SetCPUThrottlingRateResult> SetCPUThrottlingRateAsync(double rate, string? session = null, CancellationToken cancellationToken = default)

Parameters

rate double

Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetCPUThrottlingRateResult>

A task representing the asynchronous operation, containing a SetCPUThrottlingRateResult.

SetDataSaverOverrideAsync(bool?, string?, CancellationToken)

Override the value of navigator.connection.saveData

[Experimental("BIDICDP001")]
Task<SetDataSaverOverrideResult> SetDataSaverOverrideAsync(bool? dataSaverEnabled = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

dataSaverEnabled bool?

Override value. Omitting the parameter disables the override.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDataSaverOverrideResult>

A task representing the asynchronous operation, containing a SetDataSaverOverrideResult.

SetDefaultBackgroundColorOverrideAsync(RGBA?, string?, CancellationToken)

Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.

Task<SetDefaultBackgroundColorOverrideResult> SetDefaultBackgroundColorOverrideAsync(RGBA? color = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

color RGBA

RGBA of the default background color. If not specified, any existing override will be cleared.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDefaultBackgroundColorOverrideResult>

A task representing the asynchronous operation, containing a SetDefaultBackgroundColorOverrideResult.

SetDeviceMetricsOverrideAsync(long, long, double, bool, double?, long?, long?, long?, long?, bool?, ScreenOrientation?, Viewport?, DisplayFeature?, DevicePosture?, string?, bool?, string?, string?, CancellationToken)

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).

Task<SetDeviceMetricsOverrideResult> SetDeviceMetricsOverrideAsync(long width, long height, double deviceScaleFactor, bool mobile, double? scale = null, long? screenWidth = null, long? screenHeight = null, long? positionX = null, long? positionY = null, bool? dontSetVisibleSize = null, ScreenOrientation? screenOrientation = null, Viewport? viewport = null, DisplayFeature? displayFeature = null, DevicePosture? devicePosture = null, string? scrollbarType = null, bool? screenOrientationLockEmulation = null, string? viewportMeta = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

width long

Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.

height long

Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.

deviceScaleFactor double

Overriding device scale factor value. 0 disables the override.

mobile bool

Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.

scale double?

Scale to apply to resulting view image.

screenWidth long?

Overriding screen width value in pixels (minimum 0, maximum 10000000).

screenHeight long?

Overriding screen height value in pixels (minimum 0, maximum 10000000).

positionX long?

Overriding view X position on screen in pixels (minimum 0, maximum 10000000).

positionY long?

Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).

dontSetVisibleSize bool?

Do not set visible view size, rely upon explicit setVisibleSize call.

screenOrientation ScreenOrientation

Screen orientation override.

viewport Viewport

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.

displayFeature DisplayFeature

If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride.

devicePosture DevicePosture

If set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride.

scrollbarType string

Scrollbar type. Default: default.

screenOrientationLockEmulation bool?

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.

viewportMeta string

Viewport meta tag behavior. Default: default. Note: if mobile is true, the viewport meta tag is always enabled.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDeviceMetricsOverrideResult>

A task representing the asynchronous operation, containing a SetDeviceMetricsOverrideResult.

SetDevicePostureOverrideAsync(DevicePosture, string?, CancellationToken)

Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().

[Experimental("BIDICDP001")]
Task<SetDevicePostureOverrideResult> SetDevicePostureOverrideAsync(DevicePosture posture, string? session = null, CancellationToken cancellationToken = default)

Parameters

posture DevicePosture
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDevicePostureOverrideResult>

A task representing the asynchronous operation, containing a SetDevicePostureOverrideResult.

SetDisabledImageTypesAsync(ImmutableArray<DisabledImageType>, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<SetDisabledImageTypesResult> SetDisabledImageTypesAsync(ImmutableArray<DisabledImageType> imageTypes, string? session = null, CancellationToken cancellationToken = default)

Parameters

imageTypes ImmutableArray<DisabledImageType>

Image types to disable.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDisabledImageTypesResult>

A task representing the asynchronous operation, containing a SetDisabledImageTypesResult.

SetDisplayFeaturesOverrideAsync(ImmutableArray<DisplayFeature>, string?, CancellationToken)

Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().

[Experimental("BIDICDP001")]
Task<SetDisplayFeaturesOverrideResult> SetDisplayFeaturesOverrideAsync(ImmutableArray<DisplayFeature> features, string? session = null, CancellationToken cancellationToken = default)

Parameters

features ImmutableArray<DisplayFeature>
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDisplayFeaturesOverrideResult>

A task representing the asynchronous operation, containing a SetDisplayFeaturesOverrideResult.

SetDocumentCookieDisabledAsync(bool, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<SetDocumentCookieDisabledResult> SetDocumentCookieDisabledAsync(bool disabled, string? session = null, CancellationToken cancellationToken = default)

Parameters

disabled bool

Whether document.coookie API should be disabled.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetDocumentCookieDisabledResult>

A task representing the asynchronous operation, containing a SetDocumentCookieDisabledResult.

SetEmitTouchEventsForMouseAsync(bool, string?, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<SetEmitTouchEventsForMouseResult> SetEmitTouchEventsForMouseAsync(bool enabled, string? configuration = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool

Whether touch emulation based on mouse input should be enabled.

configuration string

Touch/gesture events configuration. Default: current platform.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetEmitTouchEventsForMouseResult>

A task representing the asynchronous operation, containing a SetEmitTouchEventsForMouseResult.

SetEmulatedMediaAsync(string?, ImmutableArray<MediaFeature>?, string?, CancellationToken)

Emulates the given media type or media feature for CSS media queries.

Task<SetEmulatedMediaResult> SetEmulatedMediaAsync(string? media = null, ImmutableArray<MediaFeature>? features = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

media string

Media type to emulate. Empty string disables the override.

features ImmutableArray<MediaFeature>?

Media features to emulate.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetEmulatedMediaResult>

A task representing the asynchronous operation, containing a SetEmulatedMediaResult.

SetEmulatedOSTextScaleAsync(double?, string?, CancellationToken)

Emulates the given OS text scale.

Task<SetEmulatedOSTextScaleResult> SetEmulatedOSTextScaleAsync(double? scale = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

scale double?
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetEmulatedOSTextScaleResult>

A task representing the asynchronous operation, containing a SetEmulatedOSTextScaleResult.

SetEmulatedVisionDeficiencyAsync(string, string?, CancellationToken)

Emulates the given vision deficiency.

Task<SetEmulatedVisionDeficiencyResult> SetEmulatedVisionDeficiencyAsync(string type, string? session = null, CancellationToken cancellationToken = default)

Parameters

type string

Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetEmulatedVisionDeficiencyResult>

A task representing the asynchronous operation, containing a SetEmulatedVisionDeficiencyResult.

SetFocusEmulationEnabledAsync(bool, string?, CancellationToken)

Enables or disables simulating a focused and active page.

[Experimental("BIDICDP001")]
Task<SetFocusEmulationEnabledResult> SetFocusEmulationEnabledAsync(bool enabled, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool

Whether to enable to disable focus emulation.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetFocusEmulationEnabledResult>

A task representing the asynchronous operation, containing a SetFocusEmulationEnabledResult.

SetGeolocationOverrideAsync(double?, double?, double?, double?, double?, double?, double?, string?, CancellationToken)

Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.

Task<SetGeolocationOverrideResult> SetGeolocationOverrideAsync(double? latitude = null, double? longitude = null, double? accuracy = null, double? altitude = null, double? altitudeAccuracy = null, double? heading = null, double? speed = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

latitude double?

Mock latitude

longitude double?

Mock longitude

accuracy double?

Mock accuracy

altitude double?

Mock altitude

altitudeAccuracy double?

Mock altitudeAccuracy

heading double?

Mock heading

speed double?

Mock speed

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetGeolocationOverrideResult>

A task representing the asynchronous operation, containing a SetGeolocationOverrideResult.

SetHardwareConcurrencyOverrideAsync(long, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<SetHardwareConcurrencyOverrideResult> SetHardwareConcurrencyOverrideAsync(long hardwareConcurrency, string? session = null, CancellationToken cancellationToken = default)

Parameters

hardwareConcurrency long

Hardware concurrency to report

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetHardwareConcurrencyOverrideResult>

A task representing the asynchronous operation, containing a SetHardwareConcurrencyOverrideResult.

SetIdleOverrideAsync(bool, bool, string?, CancellationToken)

Overrides the Idle state.

Task<SetIdleOverrideResult> SetIdleOverrideAsync(bool isUserActive, bool isScreenUnlocked, string? session = null, CancellationToken cancellationToken = default)

Parameters

isUserActive bool

Mock isUserActive

isScreenUnlocked bool

Mock isScreenUnlocked

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetIdleOverrideResult>

A task representing the asynchronous operation, containing a SetIdleOverrideResult.

SetLocaleOverrideAsync(string?, string?, CancellationToken)

Overrides default host system locale with the specified one.

[Experimental("BIDICDP001")]
Task<SetLocaleOverrideResult> SetLocaleOverrideAsync(string? locale = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

locale string

ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetLocaleOverrideResult>

A task representing the asynchronous operation, containing a SetLocaleOverrideResult.

SetNavigatorOverridesAsync(string, string?, CancellationToken)

Overrides value returned by the javascript navigator object.

[Experimental("BIDICDP001")]
[Obsolete]
Task<SetNavigatorOverridesResult> SetNavigatorOverridesAsync(string platform, string? session = null, CancellationToken cancellationToken = default)

Parameters

platform string

The platform navigator.platform should return.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetNavigatorOverridesResult>

A task representing the asynchronous operation, containing a SetNavigatorOverridesResult.

SetPageScaleFactorAsync(double, string?, CancellationToken)

Sets a specified page scale factor.

[Experimental("BIDICDP001")]
Task<SetPageScaleFactorResult> SetPageScaleFactorAsync(double pageScaleFactor, string? session = null, CancellationToken cancellationToken = default)

Parameters

pageScaleFactor double

Page scale factor.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetPageScaleFactorResult>

A task representing the asynchronous operation, containing a SetPageScaleFactorResult.

SetPressureSourceOverrideEnabledAsync(bool, PressureSource, PressureMetadata?, string?, CancellationToken)

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("BIDICDP001")]
Task<SetPressureSourceOverrideEnabledResult> SetPressureSourceOverrideEnabledAsync(bool enabled, PressureSource source, PressureMetadata? metadata = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool
source PressureSource
metadata PressureMetadata
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetPressureSourceOverrideEnabledResult>

A task representing the asynchronous operation, containing a SetPressureSourceOverrideEnabledResult.

SetPressureStateOverrideAsync(PressureSource, PressureState, string?, CancellationToken)

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("BIDICDP001")]
Task<SetPressureStateOverrideResult> SetPressureStateOverrideAsync(PressureSource source, PressureState state, string? session = null, CancellationToken cancellationToken = default)

Parameters

source PressureSource
state PressureState
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetPressureStateOverrideResult>

A task representing the asynchronous operation, containing a SetPressureStateOverrideResult.

SetPrimaryScreenAsync(ScreenId, string?, CancellationToken)

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("BIDICDP001")]
Task<SetPrimaryScreenResult> SetPrimaryScreenAsync(ScreenId screenId, string? session = null, CancellationToken cancellationToken = default)

Parameters

screenId ScreenId
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetPrimaryScreenResult>

A task representing the asynchronous operation, containing a SetPrimaryScreenResult.

SetSafeAreaInsetsOverrideAsync(SafeAreaInsets, string?, CancellationToken)

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("BIDICDP001")]
Task<SetSafeAreaInsetsOverrideResult> SetSafeAreaInsetsOverrideAsync(SafeAreaInsets insets, string? session = null, CancellationToken cancellationToken = default)

Parameters

insets SafeAreaInsets
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetSafeAreaInsetsOverrideResult>

A task representing the asynchronous operation, containing a SetSafeAreaInsetsOverrideResult.

SetScriptExecutionDisabledAsync(bool, string?, CancellationToken)

Switches script execution in the page.

Task<SetScriptExecutionDisabledResult> SetScriptExecutionDisabledAsync(bool value, string? session = null, CancellationToken cancellationToken = default)

Parameters

value bool

Whether script execution should be disabled in the page.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetScriptExecutionDisabledResult>

A task representing the asynchronous operation, containing a SetScriptExecutionDisabledResult.

SetScrollbarsHiddenAsync(bool, string?, CancellationToken)

[Experimental("BIDICDP001")]
Task<SetScrollbarsHiddenResult> SetScrollbarsHiddenAsync(bool hidden, string? session = null, CancellationToken cancellationToken = default)

Parameters

hidden bool

Whether scrollbars should be always hidden.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetScrollbarsHiddenResult>

A task representing the asynchronous operation, containing a SetScrollbarsHiddenResult.

SetSensorOverrideEnabledAsync(bool, SensorType, SensorMetadata?, string?, CancellationToken)

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("BIDICDP001")]
Task<SetSensorOverrideEnabledResult> SetSensorOverrideEnabledAsync(bool enabled, SensorType type, SensorMetadata? metadata = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool
type SensorType
metadata SensorMetadata
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetSensorOverrideEnabledResult>

A task representing the asynchronous operation, containing a SetSensorOverrideEnabledResult.

SetSensorOverrideReadingsAsync(SensorType, SensorReading, string?, CancellationToken)

Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.

[Experimental("BIDICDP001")]
Task<SetSensorOverrideReadingsResult> SetSensorOverrideReadingsAsync(SensorType type, SensorReading reading, string? session = null, CancellationToken cancellationToken = default)

Parameters

type SensorType
reading SensorReading
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetSensorOverrideReadingsResult>

A task representing the asynchronous operation, containing a SetSensorOverrideReadingsResult.

SetSmallViewportHeightDifferenceOverrideAsync(long, string?, CancellationToken)

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("BIDICDP001")]
Task<SetSmallViewportHeightDifferenceOverrideResult> SetSmallViewportHeightDifferenceOverrideAsync(long difference, string? session = null, CancellationToken cancellationToken = default)

Parameters

difference long

This will cause an element of size 100svh to be difference pixels smaller than an element of size 100lvh.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetSmallViewportHeightDifferenceOverrideResult>

A task representing the asynchronous operation, containing a SetSmallViewportHeightDifferenceOverrideResult.

SetTimezoneOverrideAsync(string, string?, CancellationToken)

Overrides default host system timezone with the specified one.

Task<SetTimezoneOverrideResult> SetTimezoneOverrideAsync(string timezoneId, string? session = null, CancellationToken cancellationToken = default)

Parameters

timezoneId string

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.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetTimezoneOverrideResult>

A task representing the asynchronous operation, containing a SetTimezoneOverrideResult.

SetTouchEmulationEnabledAsync(bool, long?, string?, CancellationToken)

Enables touch on platforms which do not support them.

Task<SetTouchEmulationEnabledResult> SetTouchEmulationEnabledAsync(bool enabled, long? maxTouchPoints = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

enabled bool

Whether the touch event emulation should be enabled.

maxTouchPoints long?

Maximum touch points supported. Defaults to one.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetTouchEmulationEnabledResult>

A task representing the asynchronous operation, containing a SetTouchEmulationEnabledResult.

SetUserAgentOverrideAsync(string, string?, string?, UserAgentMetadata?, string?, CancellationToken)

Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent.

Task<SetUserAgentOverrideResult> SetUserAgentOverrideAsync(string userAgent, string? acceptLanguage = null, string? platform = null, UserAgentMetadata? userAgentMetadata = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

userAgent string

User agent to use.

acceptLanguage string

Browser language to emulate.

platform string

The platform navigator.platform should return.

userAgentMetadata UserAgentMetadata

To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetUserAgentOverrideResult>

A task representing the asynchronous operation, containing a SetUserAgentOverrideResult.

SetVirtualKeyboardGeometryOverrideAsync(Rect?, string?, CancellationToken)

Overrides virtual keyboard geometry in CSS pixels, relative to the top-level viewport. The provided rect is used for navigator.virtualKeyboard.boundingRect, geometrychange events, and env(keyboard-inset-*) values on the inspected frame. The override applies independently of navigator.virtualKeyboard.overlaysContent so clients can preview overlay geometry without mutating page state. Values are rounded to the nearest CSS pixel. Omitting the rect clears the override.

[Experimental("BIDICDP001")]
Task<SetVirtualKeyboardGeometryOverrideResult> SetVirtualKeyboardGeometryOverrideAsync(Rect? keyboardRect = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

keyboardRect Rect
session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetVirtualKeyboardGeometryOverrideResult>

A task representing the asynchronous operation, containing a SetVirtualKeyboardGeometryOverrideResult.

SetVirtualTimePolicyAsync(VirtualTimePolicy, double?, long?, TimeSinceEpoch?, string?, CancellationToken)

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("BIDICDP001")]
Task<SetVirtualTimePolicyResult> SetVirtualTimePolicyAsync(VirtualTimePolicy policy, double? budget = null, long? maxVirtualTimeTaskStarvationCount = null, TimeSinceEpoch? initialVirtualTime = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

policy VirtualTimePolicy
budget double?

If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.

maxVirtualTimeTaskStarvationCount long?

If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.

initialVirtualTime TimeSinceEpoch

If set, base::Time::Now will be overridden to initially return this value.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetVirtualTimePolicyResult>

A task representing the asynchronous operation, containing a SetVirtualTimePolicyResult.

SetVisibleSizeAsync(long, long, string?, CancellationToken)

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.

[Experimental("BIDICDP001")]
[Obsolete]
Task<SetVisibleSizeResult> SetVisibleSizeAsync(long width, long height, string? session = null, CancellationToken cancellationToken = default)

Parameters

width long

Frame width (DIP).

height long

Frame height (DIP).

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<SetVisibleSizeResult>

A task representing the asynchronous operation, containing a SetVisibleSizeResult.

UpdateScreenAsync(ScreenId, long?, long?, long?, long?, WorkAreaInsets?, double?, long?, long?, string?, bool?, string?, CancellationToken)

Updates specified screen parameters. Only supported in headless mode.

[Experimental("BIDICDP001")]
Task<UpdateScreenResult> UpdateScreenAsync(ScreenId screenId, long? left = null, long? top = null, long? width = null, long? height = null, WorkAreaInsets? workAreaInsets = null, double? devicePixelRatio = null, long? rotation = null, long? colorDepth = null, string? label = null, bool? isInternal = null, string? session = null, CancellationToken cancellationToken = default)

Parameters

screenId ScreenId

Target screen identifier.

left long?

Offset of the left edge of the screen in pixels.

top long?

Offset of the top edge of the screen in pixels.

width long?

The width of the screen in pixels.

height long?

The height of the screen in pixels.

workAreaInsets WorkAreaInsets

Specifies the screen's work area.

devicePixelRatio double?

Specifies the screen's device pixel ratio.

rotation long?

Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270.

colorDepth long?

Specifies the screen's color depth in bits.

label string

Specifies the descriptive label for the screen.

isInternal bool?

Indicates whether the screen is internal to the device or external, attached to the device. Default is false.

session string

Optional CDP session override.

cancellationToken CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<UpdateScreenResult>

A task representing the asynchronous operation, containing a UpdateScreenResult.