Click or drag to resize

EmulationClient.SetDeviceMetricsOverrideAsync Method

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

Namespace: CefSharp.DevTools.Emulation
Assembly: CefSharp.Core (in CefSharp.Core.dll) Version: 129.0.110.0
Syntax
public Task<DevToolsMethodResponse> SetDeviceMetricsOverrideAsync(
	int width,
	int height,
	double deviceScaleFactor,
	bool mobile,
	double? scale = null,
	int? screenWidth = null,
	int? screenHeight = null,
	int? positionX = null,
	int? positionY = null,
	bool? dontSetVisibleSize = null,
	ScreenOrientation screenOrientation = null,
	Viewport viewport = null,
	DisplayFeature displayFeature = null,
	DevicePosture devicePosture = null
)

Parameters

width  Int32
Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
height  Int32
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  Boolean
Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, textautosizing and more.
scale  Nullable<Double>  (Optional)
Scale to apply to resulting view image.
screenWidth  Nullable<Int32>  (Optional)
Overriding screen width value in pixels (minimum 0, maximum 10000000).
screenHeight  Nullable<Int32>  (Optional)
Overriding screen height value in pixels (minimum 0, maximum 10000000).
positionX  Nullable<Int32>  (Optional)
Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
positionY  Nullable<Int32>  (Optional)
Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
dontSetVisibleSize  Nullable<Boolean>  (Optional)
Do not set visible view size, rely upon explicit setVisibleSize call.
screenOrientation  ScreenOrientation  (Optional)
Screen orientation override.
viewport  Viewport  (Optional)
If set, the visible area of the page will be overridden to this viewport. This viewportchange is not observed by the page, e.g. viewport-relative elements do not change positions.
displayFeature  DisplayFeature  (Optional)
If set, the display feature of a multi-segment screen. If not set, multi-segment supportis turned-off.
devicePosture  DevicePosture  (Optional)
If set, the posture of a foldable device. If not set the posture is setto continuous.Deprecated, use Emulation.setDevicePostureOverride.

Return Value

Task<DevToolsMethodResponse>
returns System.Threading.Tasks.Task<DevToolsMethodResponse>
See Also