public class CdpJSHandle extends JSHandle
句柄可防止引用的 JavaScript 对象被垃圾回收,除非句柄特意为 disposed。当 JSHandles 关联的框架被导航离开或父上下文被破坏时,JSHandles 会被自动处置。
句柄可用作任何评估函数(例如 Page.$eval()、Page.evaluate() 和 Page.evaluateHandle())的参数。它们被解析为其引用的对象。
| 限定符和类型 | 方法和说明 |
|---|---|
ElementHandle |
asElement()
如果句柄是 ElementHandle 的实例,则为 null 或句柄本身。
|
CDPSession |
client() |
void |
dispose()
释放句柄引用的对象以进行垃圾回收。
|
boolean |
disposed() |
Map<String,JSHandle> |
getProperties()
获取表示当前对象属性的句柄映射。
|
String |
id()
当前对象的 Protocol.Runtime.RemoteObject 的 id。
|
Object |
jsonValue()
表示引用对象的可序列化部分的普通对象
|
Realm |
realm() |
RemoteObject |
remoteObject()
提供对支持当前对象的 Protocol.Runtime.RemoteObject 的访问。
|
String |
toString()
返回 JSHandle 的字符串表示形式。
|
evaluate, evaluate, evaluateHandle, evaluateHandle, getPropertypublic Map<String,JSHandle> getProperties() throws com.fasterxml.jackson.core.JsonProcessingException
JSHandlegetProperties 在类中 JSHandlecom.fasterxml.jackson.core.JsonProcessingException - 序列化异常public CDPSession client()
public Object jsonValue() throws com.fasterxml.jackson.core.JsonProcessingException, EvaluateException
JSHandlejsonValue 在类中 JSHandlecom.fasterxml.jackson.core.JsonProcessingException - 如果对象由于循环而无法序列化,则抛出该异常。EvaluateExceptionpublic ElementHandle asElement()
JSHandlepublic RemoteObject remoteObject()
JSHandleremoteObject 在类中 JSHandleCopyright © 2020–2025. All rights reserved.