JsHandle class
JSHandle represents an in-page JavaScript object. JSHandles can be created
with the page.evaluateHandle
method.
var windowHandle = await page.evaluateHandle('() => window');
JSHandle prevents the referenced JavaScript object being garbage collected
unless the handle is disposed
. JSHandles are auto-disposed when their
origin frame gets navigated or the parent context gets destroyed.
JSHandle instances can be used as arguments in page.$eval
, page.evaluate
and page.evaluateHandle
methods.
- Implementers
Constructors
- JsHandle(ExecutionContext executionContext, RemoteObject remoteObject)
- JsHandle.fromRemoteObject(ExecutionContext context, RemoteObject remoteObject)
-
factory
Properties
- asElement → ElementHandle?
-
Returns either
null
or the object handle itself, if the object handle is an instance of ElementHandle.no setter - executionContext → ExecutionContext
-
Returns execution context the handle belongs to.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
no setter
- jsonValue → Future
-
Returns a JSON representation of the object. If the object has a
toJSON
function, it will not be called.no setter -
properties
→ Future<
Map< String, JsHandle> > -
The method returns a map with property names as keys and JSHandle instances
for the property values.
no setter
- remoteObject → RemoteObject
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → Future< void> - Stops referencing the element handle.
-
evaluate<
T> (String pageFunction, {List? args}) → Future< T?> -
This method passes this handle as the first argument to
pageFunction
. -
evaluateHandle<
T extends JsHandle> (String pageFunction, {List? args}) → Future< T> -
This method passes this handle as the first argument to
pageFunction
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
property<
T extends JsHandle> (String propertyName) → Future< T> - Fetches a single property from the referenced object.
-
propertyValue<
T> (String propertyName) → Future< T> - Fetches the jsonValue of a single property from the referenced object.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited