Class Emulation


  • public class Emulation
    extends java.lang.Object
    This domain emulates different environments for the page.
    • Constructor Summary

      Constructors 
      Constructor Description
      Emulation()  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static org.openqa.selenium.devtools.Command<java.lang.Boolean> canEmulate()
      Tells whether emulation is supported.
      static org.openqa.selenium.devtools.Command<java.lang.Void> clearDeviceMetricsOverride()
      Clears the overriden device metrics.
      static org.openqa.selenium.devtools.Command<java.lang.Void> clearGeolocationOverride()
      Clears the overriden Geolocation Position and Error.
      static org.openqa.selenium.devtools.Command<java.lang.Void> resetPageScaleFactor()
      Requests that page scale factor is reset to initial values.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setCPUThrottlingRate​(java.lang.Number rate)
      Enables CPU throttling to emulate slow CPUs.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setDefaultBackgroundColorOverride​(java.util.Optional<RGBA> color)
      Sets or clears an override of the default background color of the frame.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setDeviceMetricsOverride​(java.lang.Integer width, java.lang.Integer height, java.lang.Number deviceScaleFactor, java.lang.Boolean mobile, java.util.Optional<java.lang.Number> scale, java.util.Optional<java.lang.Integer> screenWidth, java.util.Optional<java.lang.Integer> screenHeight, java.util.Optional<java.lang.Integer> positionX, java.util.Optional<java.lang.Integer> positionY, java.util.Optional<java.lang.Boolean> dontSetVisibleSize, java.util.Optional<ScreenOrientation> screenOrientation, java.util.Optional<Viewport> viewport)
      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<java.lang.Void> setDocumentCookieDisabled​(java.lang.Boolean disabled)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> setEmitTouchEventsForMouse​(java.lang.Boolean enabled, java.util.Optional<Emulation.SetEmitTouchEventsForMouseConfiguration> configuration)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> setEmulatedMedia​(java.util.Optional<java.lang.String> media, java.util.Optional<java.util.List<MediaFeature>> features)
      Emulates the given media type or media feature for CSS media queries.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setEmulatedVisionDeficiency​(Emulation.SetEmulatedVisionDeficiencyType type)
      Emulates the given vision deficiency.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setFocusEmulationEnabled​(java.lang.Boolean enabled)
      Enables or disables simulating a focused and active page.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setGeolocationOverride​(java.util.Optional<java.lang.Number> latitude, java.util.Optional<java.lang.Number> longitude, java.util.Optional<java.lang.Number> accuracy)
      Overrides the Geolocation Position or Error.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setLocaleOverride​(java.util.Optional<java.lang.String> locale)
      Overrides default host system locale with the specified one.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setNavigatorOverrides​(java.lang.String platform)
      Deprecated.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setPageScaleFactor​(java.lang.Number pageScaleFactor)
      Sets a specified page scale factor.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setScriptExecutionDisabled​(java.lang.Boolean value)
      Switches script execution in the page.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setScrollbarsHidden​(java.lang.Boolean hidden)  
      static org.openqa.selenium.devtools.Command<java.lang.Void> setTimezoneOverride​(java.lang.String timezoneId)
      Overrides default host system timezone with the specified one.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setTouchEmulationEnabled​(java.lang.Boolean enabled, java.util.Optional<java.lang.Integer> maxTouchPoints)
      Enables touch on platforms which do not support them.
      static org.openqa.selenium.devtools.Command<java.lang.Void> setUserAgentOverride​(java.lang.String userAgent, java.util.Optional<java.lang.String> acceptLanguage, java.util.Optional<java.lang.String> platform, java.util.Optional<UserAgentMetadata> userAgentMetadata)
      Allows overriding user agent with the given string.
      static org.openqa.selenium.devtools.Command<java.lang.Number> setVirtualTimePolicy​(VirtualTimePolicy policy, java.util.Optional<java.lang.Number> budget, java.util.Optional<java.lang.Integer> maxVirtualTimeTaskStarvationCount, java.util.Optional<java.lang.Boolean> waitForNavigation, java.util.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<java.lang.Void> setVisibleSize​(java.lang.Integer width, java.lang.Integer height)
      Deprecated.
      static org.openqa.selenium.devtools.Event<java.lang.Void> virtualTimeBudgetExpired()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Emulation

        public Emulation()
    • Method Detail

      • canEmulate

        public static org.openqa.selenium.devtools.Command<java.lang.Boolean> canEmulate()
        Tells whether emulation is supported.
      • clearDeviceMetricsOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearDeviceMetricsOverride()
        Clears the overriden device metrics.
      • clearGeolocationOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> clearGeolocationOverride()
        Clears the overriden Geolocation Position and Error.
      • resetPageScaleFactor

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> resetPageScaleFactor()
        Requests that page scale factor is reset to initial values.
      • setFocusEmulationEnabled

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setFocusEmulationEnabled​(java.lang.Boolean enabled)
        Enables or disables simulating a focused and active page.
      • setCPUThrottlingRate

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setCPUThrottlingRate​(java.lang.Number rate)
        Enables CPU throttling to emulate slow CPUs.
      • setDefaultBackgroundColorOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDefaultBackgroundColorOverride​(java.util.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.
      • setDeviceMetricsOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDeviceMetricsOverride​(java.lang.Integer width,
                                                                                                    java.lang.Integer height,
                                                                                                    java.lang.Number deviceScaleFactor,
                                                                                                    java.lang.Boolean mobile,
                                                                                                    java.util.Optional<java.lang.Number> scale,
                                                                                                    java.util.Optional<java.lang.Integer> screenWidth,
                                                                                                    java.util.Optional<java.lang.Integer> screenHeight,
                                                                                                    java.util.Optional<java.lang.Integer> positionX,
                                                                                                    java.util.Optional<java.lang.Integer> positionY,
                                                                                                    java.util.Optional<java.lang.Boolean> dontSetVisibleSize,
                                                                                                    java.util.Optional<ScreenOrientation> screenOrientation,
                                                                                                    java.util.Optional<Viewport> viewport)
        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).
      • setScrollbarsHidden

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setScrollbarsHidden​(java.lang.Boolean hidden)
      • setDocumentCookieDisabled

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setDocumentCookieDisabled​(java.lang.Boolean disabled)
      • setEmitTouchEventsForMouse

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setEmitTouchEventsForMouse​(java.lang.Boolean enabled,
                                                                                                      java.util.Optional<Emulation.SetEmitTouchEventsForMouseConfiguration> configuration)
      • setEmulatedMedia

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setEmulatedMedia​(java.util.Optional<java.lang.String> media,
                                                                                            java.util.Optional<java.util.List<MediaFeature>> features)
        Emulates the given media type or media feature for CSS media queries.
      • setEmulatedVisionDeficiency

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setEmulatedVisionDeficiency​(Emulation.SetEmulatedVisionDeficiencyType type)
        Emulates the given vision deficiency.
      • setGeolocationOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setGeolocationOverride​(java.util.Optional<java.lang.Number> latitude,
                                                                                                  java.util.Optional<java.lang.Number> longitude,
                                                                                                  java.util.Optional<java.lang.Number> accuracy)
        Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
      • setNavigatorOverrides

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setNavigatorOverrides​(java.lang.String platform)
        Deprecated.
        Overrides value returned by the javascript navigator object.
      • setPageScaleFactor

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setPageScaleFactor​(java.lang.Number pageScaleFactor)
        Sets a specified page scale factor.
      • setScriptExecutionDisabled

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setScriptExecutionDisabled​(java.lang.Boolean value)
        Switches script execution in the page.
      • setTouchEmulationEnabled

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setTouchEmulationEnabled​(java.lang.Boolean enabled,
                                                                                                    java.util.Optional<java.lang.Integer> maxTouchPoints)
        Enables touch on platforms which do not support them.
      • setVirtualTimePolicy

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Number> setVirtualTimePolicy​(VirtualTimePolicy policy,
                                                                                                  java.util.Optional<java.lang.Number> budget,
                                                                                                  java.util.Optional<java.lang.Integer> maxVirtualTimeTaskStarvationCount,
                                                                                                  java.util.Optional<java.lang.Boolean> waitForNavigation,
                                                                                                  java.util.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<java.lang.Void> setLocaleOverride​(java.util.Optional<java.lang.String> locale)
        Overrides default host system locale with the specified one.
      • setTimezoneOverride

        @Beta
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setTimezoneOverride​(java.lang.String timezoneId)
        Overrides default host system timezone with the specified one.
      • setVisibleSize

        @Beta
        @Deprecated
        public static org.openqa.selenium.devtools.Command<java.lang.Void> setVisibleSize​(java.lang.Integer width,
                                                                                          java.lang.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.
      • setUserAgentOverride

        public static org.openqa.selenium.devtools.Command<java.lang.Void> setUserAgentOverride​(java.lang.String userAgent,
                                                                                                java.util.Optional<java.lang.String> acceptLanguage,
                                                                                                java.util.Optional<java.lang.String> platform,
                                                                                                java.util.Optional<UserAgentMetadata> userAgentMetadata)
        Allows overriding user agent with the given string.
      • virtualTimeBudgetExpired

        public static org.openqa.selenium.devtools.Event<java.lang.Void> virtualTimeBudgetExpired()