Class Emulation
java.lang.Object
org.openqa.selenium.devtools.v138.emulation.Emulation
This domain emulates different environments for the page.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static enum
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.openqa.selenium.devtools.Command
<Boolean> Deprecated.static org.openqa.selenium.devtools.Command
<Void> Clears the overridden device metrics.static org.openqa.selenium.devtools.Command
<Void> Clears a device posture override set with either setDeviceMetricsOverride() or setDevicePostureOverride() and starts using posture information from the platform again.static org.openqa.selenium.devtools.Command
<Void> Clears the display features override set with either setDeviceMetricsOverride() or setDisplayFeaturesOverride() and starts using display features from the platform again.static org.openqa.selenium.devtools.Command
<Void> Clears the overridden Geolocation Position and Error.static org.openqa.selenium.devtools.Command
<Void> Clears Idle state overrides.static org.openqa.selenium.devtools.Command
<Number> static org.openqa.selenium.devtools.Command
<Void> Requests that page scale factor is reset to initial values.static org.openqa.selenium.devtools.Command
<Void> setAutoDarkModeOverride
(Optional<Boolean> enabled) Automatically render all web contents using a dark theme.static org.openqa.selenium.devtools.Command
<Void> setAutomationOverride
(Boolean enabled) Allows overriding the automation flag.static org.openqa.selenium.devtools.Command
<Void> setCPUThrottlingRate
(Number rate) Enables CPU throttling to emulate slow CPUs.static org.openqa.selenium.devtools.Command
<Void> Sets or clears an override of the default background color of the frame.static org.openqa.selenium.devtools.Command
<Void> setDeviceMetricsOverride
(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional<Number> scale, Optional<Integer> screenWidth, Optional<Integer> screenHeight, Optional<Integer> positionX, Optional<Integer> positionY, Optional<Boolean> dontSetVisibleSize, Optional<ScreenOrientation> screenOrientation, Optional<Viewport> viewport, Optional<DisplayFeature> displayFeature, Optional<DevicePosture> devicePosture) 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).static org.openqa.selenium.devtools.Command
<Void> setDevicePostureOverride
(DevicePosture posture) Start reporting the given posture value to the Device Posture API.static org.openqa.selenium.devtools.Command
<Void> setDisabledImageTypes
(List<DisabledImageType> imageTypes) static org.openqa.selenium.devtools.Command
<Void> setDisplayFeaturesOverride
(List<DisplayFeature> features) Start using the given display features to pupulate the Viewport Segments API.static org.openqa.selenium.devtools.Command
<Void> setDocumentCookieDisabled
(Boolean disabled) static org.openqa.selenium.devtools.Command
<Void> setEmitTouchEventsForMouse
(Boolean enabled, Optional<Emulation.SetEmitTouchEventsForMouseConfiguration> configuration) static org.openqa.selenium.devtools.Command
<Void> setEmulatedMedia
(Optional<String> media, Optional<List<MediaFeature>> features) Emulates the given media type or media feature for CSS media queries.static org.openqa.selenium.devtools.Command
<Void> Emulates the given vision deficiency.static org.openqa.selenium.devtools.Command
<Void> setFocusEmulationEnabled
(Boolean enabled) Enables or disables simulating a focused and active page.static org.openqa.selenium.devtools.Command
<Void> setGeolocationOverride
(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy, Optional<Number> altitude, Optional<Number> altitudeAccuracy, Optional<Number> heading, Optional<Number> speed) Overrides the Geolocation Position or Error.static org.openqa.selenium.devtools.Command
<Void> setHardwareConcurrencyOverride
(Integer hardwareConcurrency) static org.openqa.selenium.devtools.Command
<Void> setIdleOverride
(Boolean isUserActive, Boolean isScreenUnlocked) Overrides the Idle state.static org.openqa.selenium.devtools.Command
<Void> setLocaleOverride
(Optional<String> locale) Overrides default host system locale with the specified one.static org.openqa.selenium.devtools.Command
<Void> setNavigatorOverrides
(String platform) Deprecated.static org.openqa.selenium.devtools.Command
<Void> setPageScaleFactor
(Number pageScaleFactor) Sets a specified page scale factor.static org.openqa.selenium.devtools.Command
<Void> setPressureDataOverride
(PressureSource source, PressureState state, Optional<Number> ownContributionEstimate) Provides a given pressure data set that will be processed and eventually be delivered to PressureObserver users.static org.openqa.selenium.devtools.Command
<Void> setPressureSourceOverrideEnabled
(Boolean enabled, PressureSource source, Optional<PressureMetadata> metadata) 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.static org.openqa.selenium.devtools.Command
<Void> setPressureStateOverride
(PressureSource source, PressureState state) TODO: OBSOLETE: To remove when setPressureDataOverride is merged.static org.openqa.selenium.devtools.Command
<Void> Overrides the values for env(safe-area-inset-*) and env(safe-area-max-inset-*).static org.openqa.selenium.devtools.Command
<Void> Switches script execution in the page.static org.openqa.selenium.devtools.Command
<Void> setScrollbarsHidden
(Boolean hidden) static org.openqa.selenium.devtools.Command
<Void> setSensorOverrideEnabled
(Boolean enabled, SensorType type, Optional<SensorMetadata> metadata) Overrides a platform sensor of a given type.static org.openqa.selenium.devtools.Command
<Void> setSensorOverrideReadings
(SensorType type, SensorReading reading) Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.static org.openqa.selenium.devtools.Command
<Void> setSmallViewportHeightDifferenceOverride
(Integer difference) Allows overriding the difference between the small and large viewport sizes, which determine the value of the `svh` and `lvh` unit, respectively.static org.openqa.selenium.devtools.Command
<Void> setTimezoneOverride
(String timezoneId) Overrides default host system timezone with the specified one.static org.openqa.selenium.devtools.Command
<Void> setTouchEmulationEnabled
(Boolean enabled, Optional<Integer> maxTouchPoints) Enables touch on platforms which do not support them.static org.openqa.selenium.devtools.Command
<Void> setUserAgentOverride
(String userAgent, Optional<String> acceptLanguage, Optional<String> platform, Optional<UserAgentMetadata> userAgentMetadata) Allows overriding user agent with the given string.static org.openqa.selenium.devtools.Command
<Number> setVirtualTimePolicy
(VirtualTimePolicy policy, Optional<Number> budget, Optional<Integer> maxVirtualTimeTaskStarvationCount, Optional<TimeSinceEpoch> initialVirtualTime) Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy.static org.openqa.selenium.devtools.Command
<Void> setVisibleSize
(Integer width, Integer height) Deprecated.static org.openqa.selenium.devtools.Event
<Void>
-
Constructor Details
-
Emulation
public Emulation()
-
-
Method Details
-
canEmulate
Deprecated.Tells whether emulation is supported. -
clearDeviceMetricsOverride
Clears the overridden device metrics. -
clearGeolocationOverride
Clears the overridden Geolocation Position and Error. -
resetPageScaleFactor
Requests that page scale factor is reset to initial values. -
setFocusEmulationEnabled
@Beta public static org.openqa.selenium.devtools.Command<Void> setFocusEmulationEnabled(Boolean enabled) Enables or disables simulating a focused and active page. -
setAutoDarkModeOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setAutoDarkModeOverride(Optional<Boolean> enabled) Automatically render all web contents using a dark theme. -
setCPUThrottlingRate
Enables CPU throttling to emulate slow CPUs. -
setDefaultBackgroundColorOverride
public static org.openqa.selenium.devtools.Command<Void> setDefaultBackgroundColorOverride(Optional<RGBA> color) Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one. -
setSafeAreaInsetsOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setSafeAreaInsetsOverride(SafeAreaInsets 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. -
setDeviceMetricsOverride
public static org.openqa.selenium.devtools.Command<Void> setDeviceMetricsOverride(Integer width, Integer height, Number deviceScaleFactor, Boolean mobile, Optional<Number> scale, Optional<Integer> screenWidth, Optional<Integer> screenHeight, Optional<Integer> positionX, Optional<Integer> positionY, Optional<Boolean> dontSetVisibleSize, Optional<ScreenOrientation> screenOrientation, Optional<Viewport> viewport, Optional<DisplayFeature> displayFeature, Optional<DevicePosture> devicePosture) 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). -
setDevicePostureOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setDevicePostureOverride(DevicePosture posture) Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride(). -
clearDevicePostureOverride
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. -
setDisplayFeaturesOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setDisplayFeaturesOverride(List<DisplayFeature> features) Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride(). -
clearDisplayFeaturesOverride
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. -
setScrollbarsHidden
-
setDocumentCookieDisabled
-
setEmitTouchEventsForMouse
@Beta public static org.openqa.selenium.devtools.Command<Void> setEmitTouchEventsForMouse(Boolean enabled, Optional<Emulation.SetEmitTouchEventsForMouseConfiguration> configuration) -
setEmulatedMedia
public static org.openqa.selenium.devtools.Command<Void> setEmulatedMedia(Optional<String> media, Optional<List<MediaFeature>> features) Emulates the given media type or media feature for CSS media queries. -
setEmulatedVisionDeficiency
public static org.openqa.selenium.devtools.Command<Void> setEmulatedVisionDeficiency(Emulation.SetEmulatedVisionDeficiencyType type) Emulates the given vision deficiency. -
setGeolocationOverride
public static org.openqa.selenium.devtools.Command<Void> setGeolocationOverride(Optional<Number> latitude, Optional<Number> longitude, Optional<Number> accuracy, Optional<Number> altitude, Optional<Number> altitudeAccuracy, Optional<Number> heading, Optional<Number> speed) Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable. -
getOverriddenSensorInformation
@Beta public static org.openqa.selenium.devtools.Command<Number> getOverriddenSensorInformation(SensorType type) -
setSensorOverrideEnabled
@Beta public static org.openqa.selenium.devtools.Command<Void> setSensorOverrideEnabled(Boolean enabled, SensorType type, Optional<SensorMetadata> metadata) 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. -
setSensorOverrideReadings
@Beta public static org.openqa.selenium.devtools.Command<Void> setSensorOverrideReadings(SensorType type, SensorReading reading) Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled. -
setPressureSourceOverrideEnabled
@Beta public static org.openqa.selenium.devtools.Command<Void> setPressureSourceOverrideEnabled(Boolean enabled, PressureSource source, Optional<PressureMetadata> metadata) 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. -
setPressureStateOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setPressureStateOverride(PressureSource source, PressureState 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. -
setPressureDataOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setPressureDataOverride(PressureSource source, PressureState state, Optional<Number> ownContributionEstimate) 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. -
setIdleOverride
public static org.openqa.selenium.devtools.Command<Void> setIdleOverride(Boolean isUserActive, Boolean isScreenUnlocked) Overrides the Idle state. -
clearIdleOverride
Clears Idle state overrides. -
setPageScaleFactor
@Beta public static org.openqa.selenium.devtools.Command<Void> setPageScaleFactor(Number pageScaleFactor) Sets a specified page scale factor. -
setScriptExecutionDisabled
Switches script execution in the page. -
setTouchEmulationEnabled
public static org.openqa.selenium.devtools.Command<Void> setTouchEmulationEnabled(Boolean enabled, Optional<Integer> maxTouchPoints) Enables touch on platforms which do not support them. -
setVirtualTimePolicy
@Beta public static org.openqa.selenium.devtools.Command<Number> setVirtualTimePolicy(VirtualTimePolicy policy, Optional<Number> budget, Optional<Integer> maxVirtualTimeTaskStarvationCount, Optional<TimeSinceEpoch> initialVirtualTime) 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. -
setLocaleOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setLocaleOverride(Optional<String> locale) Overrides default host system locale with the specified one. -
setTimezoneOverride
Overrides default host system timezone with the specified one. -
setVisibleSize
@Beta @Deprecated public static org.openqa.selenium.devtools.Command<Void> setVisibleSize(Integer width, Integer height) Deprecated.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. -
setDisabledImageTypes
@Beta public static org.openqa.selenium.devtools.Command<Void> setDisabledImageTypes(List<DisabledImageType> imageTypes) -
setHardwareConcurrencyOverride
-
setUserAgentOverride
public static org.openqa.selenium.devtools.Command<Void> setUserAgentOverride(String userAgent, Optional<String> acceptLanguage, Optional<String> platform, Optional<UserAgentMetadata> userAgentMetadata) Allows overriding user agent with the given string. `userAgentMetadata` must be set for Client Hint headers to be sent. -
setAutomationOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setAutomationOverride(Boolean enabled) Allows overriding the automation flag. -
setSmallViewportHeightDifferenceOverride
@Beta public static org.openqa.selenium.devtools.Command<Void> setSmallViewportHeightDifferenceOverride(Integer 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. -
virtualTimeBudgetExpired
-