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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
// @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 `Frame` (puppeteer-core 25.10.0), a remote object
/// served by `browser-commander serve --stdio`.
///
/// Extends [`EventEmitter`]; the inherited methods are repeated here.
Frame
);
impl Frame {
/// `EventEmitter.on`
///
/// ```text
/// on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn on(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<Frame, BridgeError> {
self.remote.call("on", vec![Some(type_), Some(handler.into().to_wire())]).await
}
/// `EventEmitter.off`
///
/// ```text
/// off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn off(&self, type_: Value, handler: Option<JsFunction>) -> Result<Frame, BridgeError> {
self.remote.call("off", vec![Some(type_), handler.map(|x| x.to_wire())]).await
}
/// `EventEmitter.emit`
///
/// ```text
/// emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean
/// ```
pub async fn emit(&self, type_: Value, event: Value) -> Result<bool, BridgeError> {
self.remote.call("emit", vec![Some(type_), Some(event)]).await
}
/// `EventEmitter.once`
///
/// ```text
/// once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
/// ```
pub async fn once(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<Frame, BridgeError> {
self.remote.call("once", vec![Some(type_), Some(handler.into().to_wire())]).await
}
/// `EventEmitter.listenerCount`
///
/// ```text
/// listenerCount(type: keyof EventsWithWildcard<Events>): number
/// ```
pub async fn listener_count(&self, type_: Value) -> Result<f64, BridgeError> {
self.remote.call("listenerCount", vec![Some(type_)]).await
}
/// `EventEmitter.removeAllListeners`
///
/// ```text
/// removeAllListeners(type?: keyof EventsWithWildcard<Events>): this
/// ```
pub async fn remove_all_listeners(&self, type_: Option<Value>) -> Result<Frame, BridgeError> {
self.remote.call("removeAllListeners", vec![type_]).await
}
/// `Frame.page`
///
/// ```text
/// page(): Page
/// ```
pub async fn page(&self) -> Result<Page, BridgeError> {
self.remote.call("page", vec![]).await
}
/// `Frame.goto`
///
/// ```text
/// goto(url: string, options?: GoToOptions): Promise<HTTPResponse | null>
/// ```
pub async fn goto(&self, url: &str, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
self.remote.call("goto", vec![Some(Value::from(url)), options]).await
}
/// `Frame.waitForNavigation`
///
/// ```text
/// waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>
/// ```
pub async fn wait_for_navigation(&self, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
self.remote.call("waitForNavigation", vec![options]).await
}
/// `Frame.frameElement`
///
/// ```text
/// frameElement(): Promise<HandleFor<HTMLIFrameElement> | null>
/// ```
pub async fn frame_element(&self) -> Result<Option<JSHandle>, BridgeError> {
self.remote.call("frameElement", vec![]).await
}
/// `Frame.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
}
/// `Frame.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
}
/// `Frame.locator`
///
/// ```text
/// locator<Selector extends string>(selector: Selector): Locator<NodeFor<Selector>>
/// locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>
/// ```
pub async fn locator(&self, selector: impl Into<JsFunction>) -> Result<Locator, BridgeError> {
self.remote.call("locator", vec![Some(selector.into().to_wire())]).await
}
/// `Frame.$`
///
/// ```text
/// $<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>
/// ```
pub async fn query_selector(&self, selector: &str) -> Result<Option<ElementHandle>, BridgeError> {
self.remote.call("$", vec![Some(Value::from(selector))]).await
}
/// `Frame.$$`
///
/// ```text
/// $$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>
/// ```
pub async fn query_selector_all(&self, selector: &str, options: Option<Value>) -> Result<Vec<ElementHandle>, BridgeError> {
self.remote.call("$$", vec![Some(Value::from(selector)), options]).await
}
/// `Frame.$eval`
///
/// ```text
/// $eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params >>(selector: Selector, pageFunction: string | Func, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
/// ```
pub async fn eval_on_selector(&self, selector: &str, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector)), Some(page_function.into().to_wire())];
call_args.extend(args.iter().map(|v| Some(v.clone())));
self.remote.call("$eval", call_args).await
}
/// `Frame.$$eval`
///
/// ```text
/// $$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: string | Func, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
/// ```
pub async fn eval_on_selector_all(&self, selector: &str, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector)), Some(page_function.into().to_wire())];
call_args.extend(args.iter().map(|v| Some(v.clone())));
self.remote.call("$$eval", call_args).await
}
/// `Frame.waitForSelector`
///
/// ```text
/// waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>
/// ```
pub async fn wait_for_selector(&self, selector: &str, options: Option<Value>) -> Result<Option<ElementHandle>, BridgeError> {
self.remote.call("waitForSelector", vec![Some(Value::from(selector)), options]).await
}
/// `Frame.waitForFunction`
///
/// ```text
/// waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: FrameWaitForFunctionOptions, ...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
}
/// `Frame.content`
///
/// ```text
/// content(): Promise<string>
/// ```
pub async fn content(&self) -> Result<String, BridgeError> {
self.remote.call("content", vec![]).await
}
/// `Frame.setContent`
///
/// ```text
/// setContent(html: string, options?: SetContentWaitForOptions): Promise<void>
/// ```
pub async fn set_content(&self, html: &str, options: Option<Value>) -> Result<(), BridgeError> {
self.remote.call("setContent", vec![Some(Value::from(html)), options]).await
}
/// `Frame.name`
///
/// ```text
/// name(): string
/// ```
pub async fn name(&self) -> Result<String, BridgeError> {
self.remote.call("name", vec![]).await
}
/// `Frame.url`
///
/// ```text
/// url(): string
/// ```
pub async fn url(&self) -> Result<String, BridgeError> {
self.remote.call("url", vec![]).await
}
/// `Frame.parentFrame`
///
/// ```text
/// parentFrame(): Frame | null
/// ```
pub async fn parent_frame(&self) -> Result<Option<Frame>, BridgeError> {
self.remote.call("parentFrame", vec![]).await
}
/// `Frame.childFrames`
///
/// ```text
/// childFrames(): Frame[]
/// ```
pub async fn child_frames(&self) -> Result<Vec<Frame>, BridgeError> {
self.remote.call("childFrames", vec![]).await
}
/// `Frame.detached`
///
/// ```text
/// get detached(): boolean
/// ```
pub async fn detached(&self) -> Result<bool, BridgeError> {
self.remote.get("detached").await
}
/// `Frame.isDetached`
///
/// ```text
/// isDetached(): boolean
/// ```
pub async fn is_detached(&self) -> Result<bool, BridgeError> {
self.remote.call("isDetached", vec![]).await
}
/// `Frame.addScriptTag`
///
/// ```text
/// addScriptTag(options: FrameAddScriptTagOptions): Promise<ElementHandle<HTMLScriptElement>>
/// ```
pub async fn add_script_tag(&self, options: Value) -> Result<ElementHandle, BridgeError> {
self.remote.call("addScriptTag", vec![Some(options)]).await
}
/// `Frame.addStyleTag`
///
/// ```text
/// addStyleTag(options: Omit<FrameAddStyleTagOptions, 'url'>): Promise<ElementHandle<HTMLStyleElement>>
/// addStyleTag(options: FrameAddStyleTagOptions): Promise<ElementHandle<HTMLLinkElement>>
/// ```
pub async fn add_style_tag(&self, options: Value) -> Result<ElementHandle, BridgeError> {
self.remote.call("addStyleTag", vec![Some(options)]).await
}
/// `Frame.click`
///
/// ```text
/// click(selector: string, options?: Readonly<ClickOptions>): Promise<void>
/// ```
pub async fn click(&self, selector: &str, options: Option<Value>) -> Result<(), BridgeError> {
self.remote.call("click", vec![Some(Value::from(selector)), options]).await
}
/// `Frame.focus`
///
/// ```text
/// focus(selector: string): Promise<void>
/// ```
pub async fn focus(&self, selector: &str) -> Result<(), BridgeError> {
self.remote.call("focus", vec![Some(Value::from(selector))]).await
}
/// `Frame.hover`
///
/// ```text
/// hover(selector: string): Promise<void>
/// ```
pub async fn hover(&self, selector: &str) -> Result<(), BridgeError> {
self.remote.call("hover", vec![Some(Value::from(selector))]).await
}
/// `Frame.select`
///
/// ```text
/// select(selector: string, ...values: string[]): Promise<string[]>
/// ```
pub async fn select(&self, selector: &str, values: &[&str]) -> Result<Vec<String>, BridgeError> {
let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector))];
call_args.extend(values.iter().map(|v| Some(Value::from(*v))));
self.remote.call("select", call_args).await
}
/// `Frame.tap`
///
/// ```text
/// tap(selector: string): Promise<void>
/// ```
pub async fn tap(&self, selector: &str) -> Result<(), BridgeError> {
self.remote.call("tap", vec![Some(Value::from(selector))]).await
}
/// `Frame.type`
///
/// ```text
/// type(selector: string, text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>
/// ```
pub async fn r#type(&self, selector: &str, text: &str, options: Option<Value>) -> Result<(), BridgeError> {
self.remote.call("type", vec![Some(Value::from(selector)), Some(Value::from(text)), options]).await
}
/// `Frame.title`
///
/// ```text
/// title(): Promise<string>
/// ```
pub async fn title(&self) -> Result<String, BridgeError> {
self.remote.call("title", vec![]).await
}
/// `Frame.extensionRealms`
///
/// ```text
/// extensionRealms(): Realm[]
/// ```
pub async fn extension_realms(&self) -> Result<Vec<Realm>, BridgeError> {
self.remote.call("extensionRealms", vec![]).await
}
}