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
// @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 `Realm` (puppeteer-core 25.10.0), a remote object
/// served by `browser-commander serve --stdio`.
Realm
);
impl Realm {
/// `Realm.origin`
///
/// ```text
/// get origin(): string | undefined
/// ```
pub async fn origin(&self) -> Result<Option<String>, BridgeError> {
self.remote.get("origin").await
}
/// `Realm.extension`
///
/// ```text
/// extension(): Promise<Extension | null>
/// ```
pub async fn extension(&self) -> Result<Option<Extension>, BridgeError> {
self.remote.call("extension", vec![]).await
}
/// `Realm.evaluateHandle`
///
/// ```text
/// evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<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
}
/// `Realm.evaluate`
///
/// ```text
/// evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<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
}
/// `Realm.waitForFunction`
///
/// ```text
/// waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: { polling?: 'raf' | 'mutation' | number; timeout?: number; root?: ElementHandle<Node>; signal?: AbortSignal; }, ...args: Params ): Promise<HandleFor<Awaited<ReturnType<Func>>>>
/// ```
pub async fn wait_for_function(&self, page_function: impl Into<JsFunction>, options: Option<Value>, args: &[Value]) -> Result<JSHandle, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire()), options];
call_args.extend(args.iter().map(|v| Some(v.clone())));
self.remote.call("waitForFunction", call_args).await
}
}