Interface EmulationAsync


public interface EmulationAsync
This domain emulates different environments for the page.
  • Method Details

    • canEmulate

      CompletableFuture<Boolean> canEmulate()
      Tells whether emulation is supported.
      Returns:
      True if emulation is supported.
    • clearDeviceMetricsOverride

      CompletableFuture<Void> clearDeviceMetricsOverride()
      Clears the overridden device metrics.
    • clearGeolocationOverride

      CompletableFuture<Void> clearGeolocationOverride()
      Clears the overridden Geolocation Position and Error.
    • clearIdleOverride

      CompletableFuture<Void> clearIdleOverride()
      Clears Idle state overrides.
    • resetPageScaleFactor

      CompletableFuture<Void> resetPageScaleFactor()
      Requests that page scale factor is reset to initial values.
    • setAutoDarkModeOverride

      CompletableFuture<Void> setAutoDarkModeOverride()
      Automatically render all web contents using a dark theme.
    • setAutoDarkModeOverride

      CompletableFuture<Void> setAutoDarkModeOverride(Boolean enabled)
      Automatically render all web contents using a dark theme.
      Parameters:
      enabled - Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
    • setAutomationOverride

      CompletableFuture<Void> setAutomationOverride(Boolean enabled)
      Allows overriding the automation flag.
      Parameters:
      enabled - Whether the override should be enabled.
    • setCPUThrottlingRate

      CompletableFuture<Void> setCPUThrottlingRate(Double rate)
      Enables CPU throttling to emulate slow CPUs.
      Parameters:
      rate - Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
    • setDefaultBackgroundColorOverride

      CompletableFuture<Void> setDefaultBackgroundColorOverride()
      Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
    • setDefaultBackgroundColorOverride

      CompletableFuture<Void> setDefaultBackgroundColorOverride(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.
      Parameters:
      color - RGBA of the default background color. If not specified, any existing override will be cleared.
    • setDeviceMetricsOverride

      CompletableFuture<Void> setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile)
      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:
      width - Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
      height - Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
      deviceScaleFactor - Overriding device scale factor value. 0 disables the override.
      mobile - Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
    • setDeviceMetricsOverride

      CompletableFuture<Void> setDeviceMetricsOverride(Integer width, Integer height, Double deviceScaleFactor, Boolean mobile, Double scale, Integer screenWidth, Integer screenHeight, Integer positionX, Integer positionY, Boolean dontSetVisibleSize, ScreenOrientation screenOrientation, Viewport viewport, DisplayFeature displayFeature)
      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:
      width - Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
      height - Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
      deviceScaleFactor - Overriding device scale factor value. 0 disables the override.
      mobile - Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
      scale - Scale to apply to resulting view image.
      screenWidth - Overriding screen width value in pixels (minimum 0, maximum 10000000).
      screenHeight - Overriding screen height value in pixels (minimum 0, maximum 10000000).
      positionX - Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
      positionY - Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
      dontSetVisibleSize - Do not set visible view size, rely upon explicit setVisibleSize call.
      screenOrientation - Screen orientation override.
      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 - If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off.
    • setDisabledImageTypes

      CompletableFuture<Void> setDisabledImageTypes(DisabledImageType imageTypes)
    • setDocumentCookieDisabled

      CompletableFuture<Void> setDocumentCookieDisabled(Boolean disabled)
    • setEmitTouchEventsForMouse

      CompletableFuture<Void> setEmitTouchEventsForMouse(Boolean enabled)
    • setEmitTouchEventsForMouse

      CompletableFuture<Void> setEmitTouchEventsForMouse(Boolean enabled, Platform configuration)
    • setEmulatedMedia

      CompletableFuture<Void> setEmulatedMedia()
      Emulates the given media type or media feature for CSS media queries.
    • setEmulatedMedia

      CompletableFuture<Void> setEmulatedMedia(String media, List<MediaFeature> features)
      Emulates the given media type or media feature for CSS media queries.
      Parameters:
      media - Media type to emulate. Empty string disables the override.
      features - Media features to emulate.
    • setEmulatedVisionDeficiency

      CompletableFuture<Void> setEmulatedVisionDeficiency(EmulatedVisionDeficiency type)
      Emulates the given vision deficiency.
      Parameters:
      type - Vision deficiency to emulate.
    • setFocusEmulationEnabled

      CompletableFuture<Void> setFocusEmulationEnabled(Boolean enabled)
      Enables or disables simulating a focused and active page.
      Parameters:
      enabled - Whether to enable to disable focus emulation.
    • setGeolocationOverride

      CompletableFuture<Void> setGeolocationOverride()
      Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
    • setGeolocationOverride

      CompletableFuture<Void> setGeolocationOverride(Double latitude, Double longitude, Double accuracy)
      Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
      Parameters:
      latitude - Mock latitude
      longitude - Mock longitude
      accuracy - Mock accuracy
    • setHardwareConcurrencyOverride

      CompletableFuture<Void> setHardwareConcurrencyOverride(Integer hardwareConcurrency)
    • setIdleOverride

      CompletableFuture<Void> setIdleOverride(Boolean isUserActive, Boolean isScreenUnlocked)
      Overrides the Idle state.
      Parameters:
      isUserActive - Mock isUserActive
      isScreenUnlocked - Mock isScreenUnlocked
    • setLocaleOverride

      CompletableFuture<Void> setLocaleOverride()
      Overrides default host system locale with the specified one.
    • setLocaleOverride

      CompletableFuture<Void> setLocaleOverride(String locale)
      Overrides default host system locale with the specified one.
      Parameters:
      locale - ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
    • setNavigatorOverrides

      @Deprecated CompletableFuture<Void> setNavigatorOverrides(String platform)
      Deprecated.
      Overrides value returned by the javascript navigator object.
      Parameters:
      platform - The platform navigator.platform should return.
    • setPageScaleFactor

      CompletableFuture<Void> setPageScaleFactor(Double pageScaleFactor)
      Sets a specified page scale factor.
      Parameters:
      pageScaleFactor - Page scale factor.
    • setScriptExecutionDisabled

      CompletableFuture<Void> setScriptExecutionDisabled(Boolean value)
      Switches script execution in the page.
      Parameters:
      value - Whether script execution should be disabled in the page.
    • setScrollbarsHidden

      CompletableFuture<Void> setScrollbarsHidden(Boolean hidden)
    • setTimezoneOverride

      CompletableFuture<Void> setTimezoneOverride(String timezoneId)
      Overrides default host system timezone with the specified one.
      Parameters:
      timezoneId - The timezone identifier. If empty, disables the override and restores default host system timezone.
    • setTouchEmulationEnabled

      CompletableFuture<Void> setTouchEmulationEnabled(Boolean enabled)
      Enables touch on platforms which do not support them.
      Parameters:
      enabled - Whether the touch event emulation should be enabled.
    • setTouchEmulationEnabled

      CompletableFuture<Void> setTouchEmulationEnabled(Boolean enabled, Integer maxTouchPoints)
      Enables touch on platforms which do not support them.
      Parameters:
      enabled - Whether the touch event emulation should be enabled.
      maxTouchPoints - Maximum touch points supported. Defaults to one.
    • setUserAgentOverride

      CompletableFuture<Void> setUserAgentOverride(String userAgent)
      Allows overriding user agent with the given string.
      Parameters:
      userAgent - User agent to use.
    • setUserAgentOverride

      CompletableFuture<Void> setUserAgentOverride(String userAgent, String acceptLanguage, String platform, UserAgentMetadata userAgentMetadata)
      Allows overriding user agent with the given string.
      Parameters:
      userAgent - User agent to use.
      acceptLanguage - Browser langugage to emulate.
      platform - The platform navigator.platform should return.
      userAgentMetadata - To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
    • setVirtualTimePolicy

      CompletableFuture<Double> setVirtualTimePolicy(VirtualTimePolicy policy)
      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.
      Returns:
      Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
    • setVirtualTimePolicy

      CompletableFuture<Double> setVirtualTimePolicy(VirtualTimePolicy policy, Double budget, Integer maxVirtualTimeTaskStarvationCount, Double 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.
      Parameters:
      budget - If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
      maxVirtualTimeTaskStarvationCount - If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
      initialVirtualTime - If set, base::Time::Now will be overridden to initially return this value.
      Returns:
      Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
    • setVisibleSize

      @Deprecated CompletableFuture<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.
      Parameters:
      width - Frame width (DIP).
      height - Frame height (DIP).