Class JSHandleImpl
- All Implemented Interfaces:
JSHandle
- Direct Known Subclasses:
ElementHandleImpl
-
Field Summary
FieldsFields inherited from class com.microsoft.playwright.impl.ChannelOwner
connection, guid, initializer, type -
Constructor Summary
ConstructorsConstructorDescriptionJSHandleImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer) -
Method Summary
Modifier and TypeMethodDescriptionReturns eithernullor the object handle itself, if the object handle is an instance ofElementHandle.voiddispose()ThejsHandle.disposemethod stops referencing the element handle.Returns the return value ofexpression.evaluateHandle(String pageFunction, Object arg) Returns the return value ofexpressionas aJSHandle.The method returns a map with **own property names** as keys and JSHandle instances for the property values.getProperty(String propertyName) Fetches a single property from the referenced object.(package private) voidhandleEvent(String event, com.google.gson.JsonObject parameters) Returns a JSON representation of the object.toString()Methods inherited from class com.microsoft.playwright.impl.ChannelOwner
adopt, disposeChannelOwner, runUntil, sendMessage, sendMessage, sendMessageAsync, toProtocolRef, withLogging, withWaitLoggingMethods inherited from class com.microsoft.playwright.impl.LoggingSupport
logApi, logApiIfEnabled, logWithTimestamp, withLoggingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.microsoft.playwright.JSHandle
evaluate, evaluateHandle
-
Field Details
-
preview
-
-
Constructor Details
-
JSHandleImpl
public JSHandleImpl(ChannelOwner parent, String type, String guid, com.google.gson.JsonObject initializer)
-
-
Method Details
-
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
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
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
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
Description copied from interface:JSHandleFetches a single property from the referenced object.- Specified by:
getPropertyin interfaceJSHandle- Parameters:
propertyName- property to get
-
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
- Overrides:
handleEventin classChannelOwner
-
toString
-