Class Emulation


  • public class Emulation
    extends java.lang.Object

    This class was built using the Chrome Remote Dev-Tools A.P.I., which is specified by two JSON-RPC Files. These files were obtained from the Chrome Dev Tools Protocol Git Hub Page, which has a "Tip of Tree" (the latest) API-Specification Page Here: JSON-RPC Protocol Specification.

    These files were converted into this Java-Browser (CDP) Library. The intention is to have them function in a similar fasion to the Node.js Tool known as 'Puppeteer', Microsoft's 'Playwright' and of course the Main-Stay 'Selenium.' The Java-HTML JAR Library merely implements the Java Types & Commands defined by Google's DevTools Protocol.

    🧠 View the Google CDP API:

    This domain emulates different environments for the page.

    The top-level description and explanation for this class (this comment, at the top this Java-Doc Page) is repeated, verbatim, across all of the domain classes which comprise Google's CDP API.

    This class is intended to be used with a Browser Instance

    These methods have been tested, to some degree, using Google Chrome. In order to use this class you must start a web-browser instance and make a connection to the browser using a Remote Debugging Port. Google-Corporation is the developer of this API, but any browser which accepts a Remote Debug Port Connection over Web-Sockets.

    Google-Chrome was used during the development process of the classes in this particular package. Lately, it has been asserted Microsoft has switched to using the Chrome Browser-Engine for its Microsoft Edge Internal Code-Base. Therefore, there may some functionality available when running the methods in this class with Microsoft-Edge.

    Check whether the your Web-Browser will allow itself to be driven by the Web-Socket RDP-Port 9223. See the examples available in package Torello.Browser to undertand how to build a PageConn and BrowserConn Web-Socket Connection, and how to build a WebSocketSender instance in order to execute the methods in this class.


    Web-Socket & JSON API:   
    Every one of the methods that reside in this class are designed to do nothing more than:

    1. Accept Parameters from the User, and "Marshall Them" into a Valid JSON-Request
    2. Transmit the Marshalled Request-JSON to a Headless Web-Browser over a Web-Socket Connection
    3. Receive BOTH that Command-Results AND any Browser Event-Firings from the Web-Socket
    4. Parse JSON Method-Results and Browser-Event Firings, and Subsequently Convert them to Standard Java-Types
    5. Report these Method-Results and Browser-Events to the User via a User-Registered, Event-Listener (Events) or a Promise Object (Command Responses / Results)

    Unlike the bulk of the Java HTML JAR Library, there is very little native Java-Code, and very little testing that may be done on any of the classes & methods in this package. The code inside these classes does nothing more than marshall-and-unmarshall Java-Types into Json-Requests (and vice-versa). The Java-Script & Browser modules inside of a Google-Chrome instance are, theoretically, handling these requests, and returning their results (or events) over the Web-Socket Connection.

    It has been asserted (by Google Chrome Developers) that some of these methods are only "partially working" or "experimental".


    Asking Chat-GPT for Help:   
    The LLM otherwise known as "Chat-GPT" does, indeed, have an expert level of knowledge about the "Remote DevTools Protocol". The API that the Chrome DevTools Protocl (CDP) exports is extremely well understood by the LLM, and generally I have found that Chat-GPT understands (by 2 or 3 orders of magnitude) better what my Auto-Generated JSON-Wrappers can do in controlling a Web-Browser than I could ever possibly hope to understand.

    Though not available today, there will soon be an automatically downloadable Token-Stream (AI Embeddings) BUTTON available on my Java-Doc Pages that should hopefully make it extremely easy to post my code-base, RAG Style, to Chat-GPT and other LLM's when 'interogating' them. Presently, because my "Get Token Stream Button" does not exist yet on any of my pages, what you can do is copy-and-paste any Method-Signature from any one of these pages and then ask Chat-GPT to explain what that Browser or Java-Script Function is actually doing. It is very likely to give you some pretty neat answers.

    I have found that every single one of the Domains, Types & Events which are offered by the CDP Protocol (though not documented very well by Google), are perfectly understood by the A.I. LLM - literally to the point where it does know (much better than I ever could) what my own code base actually does!

    Try it out, it's a lot of fun. Note that this package and these classes were originally developed solely to be able to execute the Java-Script that a browser executes when visiting a Web-Site. Complete HTML-Page Content can be scraped (using the HTML Data-Scraping Tools in Java-HTML) off of Web-Sites that have dynamic / Java-Script Generated Content.


    Conspicuous Boxed-Types Usage:
    You may notice that there are many methods that have parameters which accept, for instance, an Integer, instead of a primitive int. Just to remind the readiner, in Java Programs a Boxed Type is a standard Java-Primitive which has been converted into an Object-Reference. The use of Boxed-Types in this code base is an easy-and-fast-way to allow for the concept of "Optional Parameters" or "Optional Field Value."

    Whenever you see a method that accepts an Integer, the reason for this Parameter-Type choice is actually to allow a user to pass 'null' to it. This is a simple way to ELIDE passing any value at all to parameters which Google-Chrome would otherwise assert are "Optional." Whenever you pass 'null' to a Boxed-Types in this class, the Json-Processor will simply eliminate that Object-Property from the command altogether; and the browser will simply not receive any value for that parameter when that command is invoked.

    The Java Language Specification does not have an easy or well defined means of accepting optional method parameters; so Boxed-Types and 'null' are utilized here. Note that 'null' may be passed to any Command Method-Parameter that is listed as Optional on the Java-Doc Page description for that parameter.



    Stateless Class:
    This class neither contains any program-state, nor can it be instantiated. The @StaticFunctional Annotation may also be called 'The Spaghetti Report'. Static-Functional classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's @Stateless Annotation.

    • 1 Constructor(s), 1 declared private, zero-argument constructor
    • 45 Method(s), 45 declared static
    • 6 Field(s), 6 declared static, 6 declared final


    • Field Detail

      • virtualTimeBudgetExpired

        🡇     🗕  🗗  🗖
        public static final java.lang.String virtualTimeBudgetExpired
        Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
        EXPERIMENTAL

        This is Marker-Event. Marker-Event's are events that do not possess any data or fields at all. When such events are fired by the browser, the Web-Socket sends nothing more than the name of the event in the packet. The Java-HTML CDP Implementation (this library) has not actually created a dedicated Java Event-Type for this Browser Event.

        This specific static field is actually just declared a String.
        virtualTimeBudgetExpired has not been 'reified' into an actual nested / inner class of its own, at all.

        Eliminated Event Type
        See Also:
        Constant Field Values
      • SensorType

        🡅  🡇     🗕  🗗  🗖
        public static final ReadOnlyList<java.lang.String> SensorType
        Used to specify sensor types to emulate. See https://w3c.github.io/sensors/#automation for more information.
        EXPERIMENTAL

        String-Enumeration Type
      • VirtualTimePolicy

        🡅  🡇     🗕  🗗  🗖
        public static final ReadOnlyList<java.lang.String> VirtualTimePolicy
        advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.
        EXPERIMENTAL

        String-Enumeration Type
    • Method Detail

      • canEmulate

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Boolean> canEmulate()
        Tells whether emulation is supported.
        DEPRECATED
        Returns:
        An instance of Script<Boolean>

        This script may be executed, using Script.exec, and afterwards, a Promise <Boolean> will be returned

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may be retrieved.

        This Browser Function's Promise returns: Boolean (result)
        True if emulation is supported.
      • clearDeviceMetricsOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> clearDeviceMetricsOverride()
        Clears the overridden device metrics.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • clearDevicePostureOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> 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.
        EXPERIMENTAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • clearDisplayFeaturesOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> 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.
        EXPERIMENTAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • clearGeolocationOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> clearGeolocationOverride()
        Clears the overridden Geolocation Position and Error.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • clearIdleOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> clearIdleOverride()
        Clears Idle state overrides.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • getOverriddenSensorInformation

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Number> getOverriddenSensorInformation​
                    (java.lang.String type)
        
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        type - -
        Returns:
        An instance of Script<Number>

        This script may be executed, using Script.exec, and afterwards, a Promise <Number> will be returned

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may be retrieved.

        This Browser Function's Promise returns: Number (requestedSamplingFrequency)
      • resetPageScaleFactor

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> resetPageScaleFactor()
        Requests that page scale factor is reset to initial values.
        EXPERIMENTAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setAutoDarkModeOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setAutoDarkModeOverride​
                    (java.lang.Boolean enabled)
        
        Automatically render all web contents using a dark theme.
        EXPERIMENTAL
        Parameters:
        enabled - Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setAutomationOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setAutomationOverride​
                    (boolean enabled)
        
        Allows overriding the automation flag.
        EXPERIMENTAL
        Parameters:
        enabled - Whether the override should be enabled.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setCPUThrottlingRate

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setCPUThrottlingRate​
                    (java.lang.Number 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).
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDataSaverOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDataSaverOverride​
                    (java.lang.Boolean dataSaverEnabled)
        
        Override the value of navigator.connection.saveData
        EXPERIMENTAL
        Parameters:
        dataSaverEnabled - Override value. Omitting the parameter disables the override.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDefaultBackgroundColorOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDefaultBackgroundColorOverride​
                    (DOM.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.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDeviceMetricsOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDeviceMetricsOverride​
                    (int width,
                     int height,
                     java.lang.Number deviceScaleFactor,
                     boolean mobile,
                     java.lang.Number scale,
                     java.lang.Integer screenWidth,
                     java.lang.Integer screenHeight,
                     java.lang.Integer positionX,
                     java.lang.Integer positionY,
                     java.lang.Boolean dontSetVisibleSize,
                     Emulation.ScreenOrientation screenOrientation,
                     Page.Viewport viewport,
                     Emulation.DisplayFeature displayFeature,
                     Emulation.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).

        👍 Because of the sheer number of input parameters to this method, there is a a CommandBuilder variant to this method which may be invoked instead.

        Please View: setDeviceMetricsOverride()
        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.
        OPTIONALEXPERIMENTAL
        screenWidth - Overriding screen width value in pixels (minimum 0, maximum 10000000).
        OPTIONALEXPERIMENTAL
        screenHeight - Overriding screen height value in pixels (minimum 0, maximum 10000000).
        OPTIONALEXPERIMENTAL
        positionX - Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
        OPTIONALEXPERIMENTAL
        positionY - Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
        OPTIONALEXPERIMENTAL
        dontSetVisibleSize - Do not set visible view size, rely upon explicit setVisibleSize call.
        OPTIONALEXPERIMENTAL
        screenOrientation - Screen orientation override.
        OPTIONAL
        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.
        OPTIONALEXPERIMENTAL
        displayFeature - If set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride.
        OPTIONALEXPERIMENTALDEPRECATED
        devicePosture - If set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride.
        OPTIONALEXPERIMENTALDEPRECATED
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDevicePostureOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDevicePostureOverride​
                    (Emulation.DevicePosture posture)
        
        Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
        EXPERIMENTAL
        Parameters:
        posture - -
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDisabledImageTypes

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDisabledImageTypes​
                    (java.lang.String[] imageTypes)
        
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        imageTypes - Image types to disable.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDisplayFeaturesOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDisplayFeaturesOverride​
                    (Emulation.DisplayFeature[] features)
        
        Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
        EXPERIMENTAL
        Parameters:
        features - -
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setDocumentCookieDisabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setDocumentCookieDisabled​
                    (boolean disabled)
        
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        disabled - Whether document.coookie API should be disabled.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setEmitTouchEventsForMouse

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setEmitTouchEventsForMouse​
                    (boolean enabled,
                     java.lang.String configuration)
        
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        enabled - Whether touch emulation based on mouse input should be enabled.
        configuration - Touch/gesture events configuration. Default: current platform.
        Acceptable Values: ["desktop", "mobile"]
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setEmulatedMedia

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setEmulatedMedia​
                    (java.lang.String media,
                     Emulation.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.
        OPTIONAL
        features - Media features to emulate.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setEmulatedOSTextScale

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setEmulatedOSTextScale​
                    (java.lang.Number scale)
        
        Emulates the given OS text scale.
        Parameters:
        scale - -
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setEmulatedVisionDeficiency

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setEmulatedVisionDeficiency​
                    (java.lang.String type)
        
        Emulates the given vision deficiency.
        Parameters:
        type - Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
        Acceptable Values: ["achromatopsia", "blurredVision", "deuteranopia", "none", "protanopia", "reducedContrast", "tritanopia"]
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setFocusEmulationEnabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setFocusEmulationEnabled​
                    (boolean enabled)
        
        Enables or disables simulating a focused and active page.
        EXPERIMENTAL
        Parameters:
        enabled - Whether to enable to disable focus emulation.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setGeolocationOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setGeolocationOverride​
                    (java.lang.Number latitude,
                     java.lang.Number longitude,
                     java.lang.Number accuracy,
                     java.lang.Number altitude,
                     java.lang.Number altitudeAccuracy,
                     java.lang.Number heading,
                     java.lang.Number speed)
        
        Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.

        👍 Because of the sheer number of input parameters to this method, there is a a CommandBuilder variant to this method which may be invoked instead.

        Please View: setGeolocationOverride()
        Parameters:
        latitude - Mock latitude
        OPTIONAL
        longitude - Mock longitude
        OPTIONAL
        accuracy - Mock accuracy
        OPTIONAL
        altitude - Mock altitude
        OPTIONAL
        altitudeAccuracy - Mock altitudeAccuracy
        OPTIONAL
        heading - Mock heading
        OPTIONAL
        speed - Mock speed
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setHardwareConcurrencyOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setHardwareConcurrencyOverride​
                    (int hardwareConcurrency)
        
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        hardwareConcurrency - Hardware concurrency to report
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setIdleOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setIdleOverride​
                    (boolean isUserActive,
                     boolean isScreenUnlocked)
        
        Overrides the Idle state.
        Parameters:
        isUserActive - Mock isUserActive
        isScreenUnlocked - Mock isScreenUnlocked
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setLocaleOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setLocaleOverride​
                    (java.lang.String locale)
        
        Overrides default host system locale with the specified one.
        EXPERIMENTAL
        Parameters:
        locale - ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setNavigatorOverrides

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setNavigatorOverrides​
                    (java.lang.String platform)
        
        Overrides value returned by the javascript navigator object.
        EXPERIMENTALDEPRECATED
        Parameters:
        platform - The platform navigator.platform should return.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setPageScaleFactor

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setPageScaleFactor​
                    (java.lang.Number pageScaleFactor)
        
        Sets a specified page scale factor.
        EXPERIMENTAL
        Parameters:
        pageScaleFactor - Page scale factor.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setPressureDataOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setPressureDataOverride​
                    (java.lang.String source,
                     java.lang.String state,
                     java.lang.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.
        EXPERIMENTAL
        Parameters:
        source - -
        state - -
        ownContributionEstimate - -
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setPressureSourceOverrideEnabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setPressureSourceOverrideEnabled​
                    (boolean enabled,
                     java.lang.String source,
                     Emulation.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.
        EXPERIMENTAL
        Parameters:
        enabled - -
        source - -
        metadata - -
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setPressureStateOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setPressureStateOverride​
                    (java.lang.String source,
                     java.lang.String 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.
        EXPERIMENTAL
        Parameters:
        source - -
        state - -
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setSafeAreaInsetsOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setSafeAreaInsetsOverride​
                    (Emulation.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.
        EXPERIMENTAL
        Parameters:
        insets - -
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setScriptExecutionDisabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setScriptExecutionDisabled​
                    (boolean value)
        
        Switches script execution in the page.
        Parameters:
        value - Whether script execution should be disabled in the page.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setScrollbarsHidden

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setScrollbarsHidden​(boolean hidden)
        [No Description Provided by Google]
        EXPERIMENTAL
        Parameters:
        hidden - Whether scrollbars should be always hidden.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setSensorOverrideEnabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setSensorOverrideEnabled​
                    (boolean enabled,
                     java.lang.String type,
                     Emulation.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.
        EXPERIMENTAL
        Parameters:
        enabled - -
        type - -
        metadata - -
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setSensorOverrideReadings

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setSensorOverrideReadings​
                    (java.lang.String type,
                     Emulation.SensorReading reading)
        
        Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
        EXPERIMENTAL
        Parameters:
        type - -
        reading - -
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setSmallViewportHeightDifferenceOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setSmallViewportHeightDifferenceOverride​
                    (int 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.
        EXPERIMENTAL
        Parameters:
        difference - This will cause an element of size 100svh to be difference pixels smaller than an element of size 100lvh.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setTimezoneOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setTimezoneOverride​
                    (java.lang.String timezoneId)
        
        Overrides default host system timezone with the specified one.
        Parameters:
        timezoneId - The timezone identifier. List of supported timezones: https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt If empty, disables the override and restores default host system timezone.
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setTouchEmulationEnabled

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setTouchEmulationEnabled​
                    (boolean enabled,
                     java.lang.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.
        OPTIONAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setUserAgentOverride

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setUserAgentOverride​
                    (java.lang.String userAgent,
                     java.lang.String acceptLanguage,
                     java.lang.String platform,
                     Emulation.UserAgentMetadata userAgentMetadata)
        
        Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent.
        Parameters:
        userAgent - User agent to use.
        acceptLanguage - Browser language to emulate.
        OPTIONAL
        platform - The platform navigator.platform should return.
        OPTIONAL
        userAgentMetadata - To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
        OPTIONALEXPERIMENTAL
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.
      • setVirtualTimePolicy

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Number> setVirtualTimePolicy​
                    (java.lang.String policy,
                     java.lang.Number budget,
                     java.lang.Integer maxVirtualTimeTaskStarvationCount,
                     java.lang.Number 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.
        EXPERIMENTAL
        Parameters:
        policy - -
        budget - If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
        OPTIONAL
        maxVirtualTimeTaskStarvationCount - If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
        OPTIONAL
        initialVirtualTime - If set, base::Time::Now will be overridden to initially return this value.
        OPTIONAL
        Returns:
        An instance of Script<Number>

        This script may be executed, using Script.exec, and afterwards, a Promise <Number> will be returned

        Finally, the Promise may be awaited, using Promise.await(), and the returned result of this Browser Function may be retrieved.

        This Browser Function's Promise returns: Number (virtualTimeTicksBase)
        Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
      • setVisibleSize

        🡅  🡇     🗕  🗗  🗖
        public static Script<java.lang.Void> setVisibleSize​(int width,
                                                            int height)
        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.
        EXPERIMENTALDEPRECATED
        Parameters:
        width - Frame width (DIP).
        height - Frame height (DIP).
        Returns:
        An instance of Script<Void>

        This Script instance must be executed before the browser receives the invocation-request.

        This Browser-Function does not have a return-value. You may choose to await the Promise<Void> to ensure that the Browser Function has run to completion.