1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// @generated by scripts/generate-puppeteer-bindings.mjs from
// rust/protocol/puppeteer/api.json. Do not edit by hand.
#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
use serde_json::Value;
use super::*;
use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
remote_type!(
/// Puppeteer's `JSHandle` (puppeteer-core 25.10.0), a remote object
/// served by `browser-commander serve --stdio`.
JSHandle
);
impl JSHandle {
/// `JSHandle.evaluate`
///
/// ```text
/// evaluate<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
/// ```
pub async fn evaluate(&self, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire())];
call_args.extend(args.iter().map(|v| Some(v.clone())));
self.remote.call("evaluate", call_args).await
}
/// `JSHandle.evaluateHandle`
///
/// ```text
/// evaluateHandle<Params extends unknown[], Func extends EvaluateFuncWith<T, Params> = EvaluateFuncWith<T, Params>>(pageFunction: Func | string, ...args: Params ): Promise<HandleFor<Awaited<ReturnType<Func>>>>
/// ```
pub async fn evaluate_handle(&self, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<JSHandle, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire())];
call_args.extend(args.iter().map(|v| Some(v.clone())));
self.remote.call("evaluateHandle", call_args).await
}
/// `JSHandle.getProperty`
///
/// ```text
/// getProperty<K extends keyof T>(propertyName: HandleOr<K>): Promise<HandleFor<T[K]>>
/// getProperty(propertyName: string): Promise<JSHandle<unknown>>
/// ```
pub async fn get_property(&self, property_name: Value) -> Result<JSHandle, BridgeError> {
self.remote.call("getProperty", vec![Some(property_name)]).await
}
/// `JSHandle.getProperties`
///
/// ```text
/// getProperties(): Promise<Map<string, JSHandle>>
/// ```
pub async fn get_properties(&self) -> Result<Value, BridgeError> {
self.remote.call("getProperties", vec![]).await
}
/// `JSHandle.jsonValue`
///
/// ```text
/// jsonValue(): Promise<T>
/// ```
pub async fn json_value(&self) -> Result<Value, BridgeError> {
self.remote.call("jsonValue", vec![]).await
}
/// `JSHandle.asElement`
///
/// ```text
/// asElement(): ElementHandle<Node> | null
/// ```
pub async fn as_element(&self) -> Result<Option<ElementHandle>, BridgeError> {
self.remote.call("asElement", vec![]).await
}
/// `JSHandle.dispose`
///
/// ```text
/// dispose(): Promise<void>
/// ```
pub async fn dispose(&self) -> Result<(), BridgeError> {
self.remote.call("dispose", vec![]).await
}
/// `JSHandle.toString`
///
/// ```text
/// toString(): string
/// ```
pub async fn to_string(&self) -> Result<String, BridgeError> {
self.remote.call("toString", vec![]).await
}
/// `JSHandle.remoteObject`
///
/// ```text
/// remoteObject(): Protocol.Runtime.RemoteObject
/// ```
pub async fn remote_object(&self) -> Result<Value, BridgeError> {
self.remote.call("remoteObject", vec![]).await
}
}