Interface Emulation


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

    • canEmulate

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

      void clearDeviceMetricsOverride()
      Clears the overridden device metrics.
    • clearGeolocationOverride

      void clearGeolocationOverride()
      Clears the overridden Geolocation Position and Error.
    • clearIdleOverride

      void clearIdleOverride()
      Clears Idle state overrides.
    • resetPageScaleFactor

      void resetPageScaleFactor()
      Requests that page scale factor is reset to initial values.
    • setAutoDarkModeOverride

      void setAutoDarkModeOverride()
      Automatically render all web contents using a dark theme.
    • setAutoDarkModeOverride

      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

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

      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

      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

      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

      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

      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

      void setDisabledImageTypes(DisabledImageType imageTypes)
    • setDocumentCookieDisabled

      void setDocumentCookieDisabled(Boolean disabled)
    • setEmitTouchEventsForMouse

      void setEmitTouchEventsForMouse(Boolean enabled)
    • setEmitTouchEventsForMouse

      void setEmitTouchEventsForMouse(Boolean enabled, Platform configuration)
    • setEmulatedMedia

      void setEmulatedMedia()
      Emulates the given media type or media feature for CSS media queries.
    • setEmulatedMedia

      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

      void setEmulatedVisionDeficiency(EmulatedVisionDeficiency type)
      Emulates the given vision deficiency.
      Parameters:
      type - Vision deficiency to emulate.
    • setFocusEmulationEnabled

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

      void setGeolocationOverride()
      Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
    • setGeolocationOverride

      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

      void setHardwareConcurrencyOverride(Integer hardwareConcurrency)
    • setIdleOverride

      void setIdleOverride(Boolean isUserActive, Boolean isScreenUnlocked)
      Overrides the Idle state.
      Parameters:
      isUserActive - Mock isUserActive
      isScreenUnlocked - Mock isScreenUnlocked
    • setLocaleOverride

      void setLocaleOverride()
      Overrides default host system locale with the specified one.
    • setLocaleOverride

      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 void setNavigatorOverrides(String platform)
      Deprecated.
      Overrides value returned by the javascript navigator object.
      Parameters:
      platform - The platform navigator.platform should return.
    • setPageScaleFactor

      void setPageScaleFactor(Double pageScaleFactor)
      Sets a specified page scale factor.
      Parameters:
      pageScaleFactor - Page scale factor.
    • setScriptExecutionDisabled

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

      void setScrollbarsHidden(Boolean hidden)
    • setTimezoneOverride

      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

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

      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

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

      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

      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

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