Class JSHandleImpl

    • Field Detail

      • preview

        private java.lang.String preview
    • Constructor Detail

      • JSHandleImpl

        public JSHandleImpl​(ChannelOwner parent,
                            java.lang.String type,
                            java.lang.String guid,
                            com.google.gson.JsonObject initializer)
    • Method Detail

      • asElement

        public ElementHandle asElement()
        Description copied from interface: JSHandle
        Returns either null or the object handle itself, if the object handle is an instance of ElementHandle.
        Specified by:
        asElement in interface JSHandle
      • dispose

        public void dispose()
        Description copied from interface: JSHandle
        The jsHandle.dispose method stops referencing the element handle.
        Specified by:
        dispose in interface JSHandle
      • evaluate

        public java.lang.Object evaluate​(java.lang.String pageFunction,
                                         java.lang.Object arg)
        Description copied from interface: JSHandle
        Returns the return value of expression.

        This method passes this handle as the first argument to expression.

        If expression returns a Promise, then handle.evaluate would wait for the promise to resolve and return its value.

        **Usage**

        
         ElementHandle tweetHandle = page.querySelector(".tweet .retweets");
         assertEquals("10 retweets", tweetHandle.evaluate("node => node.innerText"));
         
        Specified by:
        evaluate in interface JSHandle
        Parameters:
        pageFunction - JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
        arg - Optional argument to pass to expression.
      • evaluateHandle

        public JSHandle evaluateHandle​(java.lang.String pageFunction,
                                       java.lang.Object arg)
        Description copied from interface: JSHandle
        Returns the return value of expression as a JSHandle.

        This method passes this handle as the first argument to expression.

        The only difference between jsHandle.evaluate and jsHandle.evaluateHandle is that jsHandle.evaluateHandle returns JSHandle.

        If the function passed to the jsHandle.evaluateHandle returns a Promise, then jsHandle.evaluateHandle would wait for the promise to resolve and return its value.

        See Page.evaluateHandle() for more details.

        Specified by:
        evaluateHandle in interface JSHandle
        Parameters:
        pageFunction - JavaScript expression to be evaluated in the browser context. If the expression evaluates to a function, the function is automatically invoked.
        arg - Optional argument to pass to expression.
      • getProperties

        public java.util.Map<java.lang.String,​JSHandle> getProperties()
        Description copied from interface: JSHandle
        The method returns a map with **own property names** as keys and JSHandle instances for the property values.

        **Usage**

        
         JSHandle handle = page.evaluateHandle("() => ({ window, document })");
         Map<String, JSHandle> properties = handle.getProperties();
         JSHandle windowHandle = properties.get("window");
         JSHandle documentHandle = properties.get("document");
         handle.dispose();
         
        Specified by:
        getProperties in interface JSHandle
      • getProperty

        public JSHandle getProperty​(java.lang.String propertyName)
        Description copied from interface: JSHandle
        Fetches a single property from the referenced object.
        Specified by:
        getProperty in interface JSHandle
        Parameters:
        propertyName - property to get
      • jsonValue

        public java.lang.Object jsonValue()
        Description copied from interface: JSHandle
        Returns a JSON representation of the object. If the object has a toJSON function, it **will not be called**.

        NOTE: The method will return an empty JSON object if the referenced object is not stringifiable. It will throw an error if the object has circular references.

        Specified by:
        jsonValue in interface JSHandle
      • handleEvent

        void handleEvent​(java.lang.String event,
                         com.google.gson.JsonObject parameters)
        Overrides:
        handleEvent in class ChannelOwner
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object