Class JSHandleImpl
- java.lang.Object
-
- com.microsoft.playwright.impl.LoggingSupport
-
- com.microsoft.playwright.impl.ChannelOwner
-
- com.microsoft.playwright.impl.JSHandleImpl
-
- All Implemented Interfaces:
JSHandle
- Direct Known Subclasses:
ElementHandleImpl
public class JSHandleImpl extends ChannelOwner implements JSHandle
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringpreview-
Fields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type
-
-
Constructor Summary
Constructors Constructor Description JSHandleImpl(ChannelOwner parent, java.lang.String type, java.lang.String guid, com.google.gson.JsonObject initializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ElementHandleasElement()Returns eithernullor the object handle itself, if the object handle is an instance ofElementHandle.voiddispose()ThejsHandle.disposemethod stops referencing the element handle.java.lang.Objectevaluate(java.lang.String pageFunction, java.lang.Object arg)Returns the return value ofexpression.JSHandleevaluateHandle(java.lang.String pageFunction, java.lang.Object arg)Returns the return value ofexpressionas aJSHandle.java.util.Map<java.lang.String,JSHandle>getProperties()The method returns a map with **own property names** as keys and JSHandle instances for the property values.JSHandlegetProperty(java.lang.String propertyName)Fetches a single property from the referenced object.(package private) voidhandleEvent(java.lang.String event, com.google.gson.JsonObject parameters)java.lang.ObjectjsonValue()Returns a JSON representation of the object.java.lang.StringtoString()-
Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLogging
-
Methods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLogging
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.microsoft.playwright.JSHandle
evaluate, evaluateHandle
-
-
-
-
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:JSHandleReturns eithernullor the object handle itself, if the object handle is an instance ofElementHandle.
-
dispose
public void dispose()
Description copied from interface:JSHandleThejsHandle.disposemethod stops referencing the element handle.
-
evaluate
public java.lang.Object evaluate(java.lang.String pageFunction, java.lang.Object arg)Description copied from interface:JSHandleReturns the return value ofexpression.This method passes this handle as the first argument to
expression.If
expressionreturns a Promise, thenhandle.evaluatewould 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"));
-
evaluateHandle
public JSHandle evaluateHandle(java.lang.String pageFunction, java.lang.Object arg)
Description copied from interface:JSHandleReturns the return value ofexpressionas aJSHandle.This method passes this handle as the first argument to
expression.The only difference between
jsHandle.evaluateandjsHandle.evaluateHandleis thatjsHandle.evaluateHandlereturnsJSHandle.If the function passed to the
jsHandle.evaluateHandlereturns a Promise, thenjsHandle.evaluateHandlewould wait for the promise to resolve and return its value.See
Page.evaluateHandle()for more details.- Specified by:
evaluateHandlein interfaceJSHandle- 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 toexpression.
-
getProperties
public java.util.Map<java.lang.String,JSHandle> getProperties()
Description copied from interface:JSHandleThe 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:
getPropertiesin interfaceJSHandle
-
getProperty
public JSHandle getProperty(java.lang.String propertyName)
Description copied from interface:JSHandleFetches a single property from the referenced object.- Specified by:
getPropertyin interfaceJSHandle- Parameters:
propertyName- property to get
-
jsonValue
public java.lang.Object jsonValue()
Description copied from interface:JSHandleReturns a JSON representation of the object. If the object has atoJSONfunction, 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.
-
handleEvent
void handleEvent(java.lang.String event, com.google.gson.JsonObject parameters)- Overrides:
handleEventin classChannelOwner
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-