Skip to main content

browser_commander/puppeteer/api/
page.rs

1// @generated by scripts/generate-puppeteer-bindings.mjs from
2// rust/protocol/puppeteer/api.json. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
5
6use serde_json::Value;
7
8use super::*;
9use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
10
11remote_type!(
12    /// Puppeteer's `Page` (puppeteer-core 25.12.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    ///
15    /// Extends [`EventEmitter`]; the inherited methods are repeated here.
16    Page
17);
18
19impl Page {
20    /// `EventEmitter.on`
21    ///
22    /// ```text
23    /// on<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
24    /// ```
25    pub async fn on(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<Page, BridgeError> {
26        self.remote.call("on", vec![Some(type_), Some(handler.into().to_wire())]).await
27    }
28
29    /// `EventEmitter.off`
30    ///
31    /// ```text
32    /// off<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler?: Handler<EventsWithWildcard<Events>[Key]>): this
33    /// ```
34    pub async fn off(&self, type_: Value, handler: Option<JsFunction>) -> Result<Page, BridgeError> {
35        self.remote.call("off", vec![Some(type_), handler.map(|x| x.to_wire())]).await
36    }
37
38    /// `EventEmitter.emit`
39    ///
40    /// ```text
41    /// emit<Key extends keyof EventsWithWildcard<Events>>(type: Key, event: EventsWithWildcard<Events>[Key]): boolean
42    /// ```
43    pub async fn emit(&self, type_: Value, event: Value) -> Result<bool, BridgeError> {
44        self.remote.call("emit", vec![Some(type_), Some(event)]).await
45    }
46
47    /// `EventEmitter.once`
48    ///
49    /// ```text
50    /// once<Key extends keyof EventsWithWildcard<Events>>(type: Key, handler: Handler<EventsWithWildcard<Events>[Key]>): this
51    /// ```
52    pub async fn once(&self, type_: Value, handler: impl Into<JsFunction>) -> Result<Page, BridgeError> {
53        self.remote.call("once", vec![Some(type_), Some(handler.into().to_wire())]).await
54    }
55
56    /// `EventEmitter.listenerCount`
57    ///
58    /// ```text
59    /// listenerCount(type: keyof EventsWithWildcard<Events>): number
60    /// ```
61    pub async fn listener_count(&self, type_: Value) -> Result<f64, BridgeError> {
62        self.remote.call("listenerCount", vec![Some(type_)]).await
63    }
64
65    /// `EventEmitter.removeAllListeners`
66    ///
67    /// ```text
68    /// removeAllListeners(type?: keyof EventsWithWildcard<Events>): this
69    /// ```
70    pub async fn remove_all_listeners(&self, type_: Option<Value>) -> Result<Page, BridgeError> {
71        self.remote.call("removeAllListeners", vec![type_]).await
72    }
73
74    /// `Page.isServiceWorkerBypassed`
75    ///
76    /// ```text
77    /// isServiceWorkerBypassed(): boolean
78    /// ```
79    pub async fn is_service_worker_bypassed(&self) -> Result<bool, BridgeError> {
80        self.remote.call("isServiceWorkerBypassed", vec![]).await
81    }
82
83    /// `Page.isDragInterceptionEnabled`
84    ///
85    /// ```text
86    /// isDragInterceptionEnabled(): boolean
87    /// ```
88    pub async fn is_drag_interception_enabled(&self) -> Result<bool, BridgeError> {
89        self.remote.call("isDragInterceptionEnabled", vec![]).await
90    }
91
92    /// `Page.isJavaScriptEnabled`
93    ///
94    /// ```text
95    /// isJavaScriptEnabled(): boolean
96    /// ```
97    pub async fn is_java_script_enabled(&self) -> Result<bool, BridgeError> {
98        self.remote.call("isJavaScriptEnabled", vec![]).await
99    }
100
101    /// `Page.waitForFileChooser`
102    ///
103    /// ```text
104    /// waitForFileChooser(options?: WaitTimeoutOptions): Promise<FileChooser>
105    /// ```
106    pub async fn wait_for_file_chooser(&self, options: Option<Value>) -> Result<FileChooser, BridgeError> {
107        self.remote.call("waitForFileChooser", vec![options]).await
108    }
109
110    /// `Page.setGeolocation`
111    ///
112    /// ```text
113    /// setGeolocation(options: GeolocationOptions): Promise<void>
114    /// ```
115    pub async fn set_geolocation(&self, options: Value) -> Result<(), BridgeError> {
116        self.remote.call("setGeolocation", vec![Some(options)]).await
117    }
118
119    /// `Page.target`
120    ///
121    /// ```text
122    /// target(): Target
123    /// ```
124    pub async fn target(&self) -> Result<Target, BridgeError> {
125        self.remote.call("target", vec![]).await
126    }
127
128    /// `Page.browser`
129    ///
130    /// ```text
131    /// browser(): Browser
132    /// ```
133    pub async fn browser(&self) -> Result<Browser, BridgeError> {
134        self.remote.call("browser", vec![]).await
135    }
136
137    /// `Page.browserContext`
138    ///
139    /// ```text
140    /// browserContext(): BrowserContext
141    /// ```
142    pub async fn browser_context(&self) -> Result<BrowserContext, BridgeError> {
143        self.remote.call("browserContext", vec![]).await
144    }
145
146    /// `Page.mainFrame`
147    ///
148    /// ```text
149    /// mainFrame(): Frame
150    /// ```
151    pub async fn main_frame(&self) -> Result<Frame, BridgeError> {
152        self.remote.call("mainFrame", vec![]).await
153    }
154
155    /// `Page.createCDPSession`
156    ///
157    /// ```text
158    /// createCDPSession(): Promise<CDPSession>
159    /// ```
160    pub async fn create_cdp_session(&self) -> Result<CDPSession, BridgeError> {
161        self.remote.call("createCDPSession", vec![]).await
162    }
163
164    /// `Page.keyboard`
165    ///
166    /// ```text
167    /// get keyboard(): Keyboard
168    /// ```
169    pub async fn keyboard(&self) -> Result<Keyboard, BridgeError> {
170        self.remote.get("keyboard").await
171    }
172
173    /// `Page.touchscreen`
174    ///
175    /// ```text
176    /// get touchscreen(): Touchscreen
177    /// ```
178    pub async fn touchscreen(&self) -> Result<Touchscreen, BridgeError> {
179        self.remote.get("touchscreen").await
180    }
181
182    /// `Page.coverage`
183    ///
184    /// ```text
185    /// get coverage(): Coverage
186    /// ```
187    pub async fn coverage(&self) -> Result<Coverage, BridgeError> {
188        self.remote.get("coverage").await
189    }
190
191    /// `Page.tracing`
192    ///
193    /// ```text
194    /// get tracing(): Tracing
195    /// ```
196    pub async fn tracing(&self) -> Result<Tracing, BridgeError> {
197        self.remote.get("tracing").await
198    }
199
200    /// `Page.webmcp`
201    ///
202    /// ```text
203    /// get webmcp(): WebMCP
204    /// ```
205    pub async fn webmcp(&self) -> Result<WebMCP, BridgeError> {
206        self.remote.get("webmcp").await
207    }
208
209    /// `Page.accessibility`
210    ///
211    /// ```text
212    /// get accessibility(): Accessibility
213    /// ```
214    pub async fn accessibility(&self) -> Result<Accessibility, BridgeError> {
215        self.remote.get("accessibility").await
216    }
217
218    /// `Page.frames`
219    ///
220    /// ```text
221    /// frames(): Frame[]
222    /// ```
223    pub async fn frames(&self) -> Result<Vec<Frame>, BridgeError> {
224        self.remote.call("frames", vec![]).await
225    }
226
227    /// `Page.workers`
228    ///
229    /// ```text
230    /// workers(): WebWorker[]
231    /// ```
232    pub async fn workers(&self) -> Result<Vec<WebWorker>, BridgeError> {
233        self.remote.call("workers", vec![]).await
234    }
235
236    /// `Page.setRequestInterception`
237    ///
238    /// ```text
239    /// setRequestInterception(value: boolean): Promise<void>
240    /// ```
241    pub async fn set_request_interception(&self, value: bool) -> Result<(), BridgeError> {
242        self.remote.call("setRequestInterception", vec![Some(Value::from(value))]).await
243    }
244
245    /// `Page.setBypassServiceWorker`
246    ///
247    /// ```text
248    /// setBypassServiceWorker(bypass: boolean): Promise<void>
249    /// ```
250    pub async fn set_bypass_service_worker(&self, bypass: bool) -> Result<(), BridgeError> {
251        self.remote.call("setBypassServiceWorker", vec![Some(Value::from(bypass))]).await
252    }
253
254    /// `Page.setDragInterception`
255    ///
256    /// ```text
257    /// setDragInterception(enabled: boolean): Promise<void>
258    /// ```
259    pub async fn set_drag_interception(&self, enabled: bool) -> Result<(), BridgeError> {
260        self.remote.call("setDragInterception", vec![Some(Value::from(enabled))]).await
261    }
262
263    /// `Page.setOfflineMode`
264    ///
265    /// ```text
266    /// setOfflineMode(enabled: boolean): Promise<void>
267    /// ```
268    pub async fn set_offline_mode(&self, enabled: bool) -> Result<(), BridgeError> {
269        self.remote.call("setOfflineMode", vec![Some(Value::from(enabled))]).await
270    }
271
272    /// `Page.emulateNetworkConditions`
273    ///
274    /// ```text
275    /// emulateNetworkConditions(networkConditions: NetworkConditions | null): Promise<void>
276    /// ```
277    pub async fn emulate_network_conditions(&self, network_conditions: Option<Value>) -> Result<(), BridgeError> {
278        self.remote.call("emulateNetworkConditions", vec![Some(network_conditions.unwrap_or(Value::Null))]).await
279    }
280
281    /// `Page.setDefaultNavigationTimeout`
282    ///
283    /// ```text
284    /// setDefaultNavigationTimeout(timeout: number): void
285    /// ```
286    pub async fn set_default_navigation_timeout(&self, timeout: f64) -> Result<(), BridgeError> {
287        self.remote.call("setDefaultNavigationTimeout", vec![Some(Value::from(timeout))]).await
288    }
289
290    /// `Page.setDefaultTimeout`
291    ///
292    /// ```text
293    /// setDefaultTimeout(timeout: number): void
294    /// ```
295    pub async fn set_default_timeout(&self, timeout: f64) -> Result<(), BridgeError> {
296        self.remote.call("setDefaultTimeout", vec![Some(Value::from(timeout))]).await
297    }
298
299    /// `Page.getDefaultTimeout`
300    ///
301    /// ```text
302    /// getDefaultTimeout(): number
303    /// ```
304    pub async fn get_default_timeout(&self) -> Result<f64, BridgeError> {
305        self.remote.call("getDefaultTimeout", vec![]).await
306    }
307
308    /// `Page.getDefaultNavigationTimeout`
309    ///
310    /// ```text
311    /// getDefaultNavigationTimeout(): number
312    /// ```
313    pub async fn get_default_navigation_timeout(&self) -> Result<f64, BridgeError> {
314        self.remote.call("getDefaultNavigationTimeout", vec![]).await
315    }
316
317    /// `Page.locator`
318    ///
319    /// ```text
320    /// locator<Selector extends string>(selector: Selector): Locator<NodeFor<Selector>>
321    /// locator<Ret>(func: () => Awaitable<Ret>): Locator<Ret>
322    /// ```
323    pub async fn locator(&self, selector: impl Into<JsFunction>) -> Result<Locator, BridgeError> {
324        self.remote.call("locator", vec![Some(selector.into().to_wire())]).await
325    }
326
327    /// `Page.$`
328    ///
329    /// ```text
330    /// $<Selector extends string>(selector: Selector): Promise<ElementHandle<NodeFor<Selector>> | null>
331    /// ```
332    pub async fn query_selector(&self, selector: &str) -> Result<Option<ElementHandle>, BridgeError> {
333        self.remote.call("$", vec![Some(Value::from(selector))]).await
334    }
335
336    /// `Page.$$`
337    ///
338    /// ```text
339    /// $$<Selector extends string>(selector: Selector, options?: QueryOptions): Promise<Array<ElementHandle<NodeFor<Selector>>>>
340    /// ```
341    pub async fn query_selector_all(&self, selector: &str, options: Option<Value>) -> Result<Vec<ElementHandle>, BridgeError> {
342        self.remote.call("$$", vec![Some(Value::from(selector)), options]).await
343    }
344
345    /// `Page.evaluateHandle`
346    ///
347    /// ```text
348    /// evaluateHandle<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params ): Promise<HandleFor<Awaited<ReturnType<Func>>>>
349    /// ```
350    pub async fn evaluate_handle(&self, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<JSHandle, BridgeError> {
351        let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire())];
352        call_args.extend(args.iter().map(|v| Some(v.clone())));
353        self.remote.call("evaluateHandle", call_args).await
354    }
355
356    /// `Page.queryObjects`
357    ///
358    /// ```text
359    /// queryObjects<Prototype>(prototypeHandle: JSHandle<Prototype>): Promise<JSHandle<Prototype[]>>
360    /// ```
361    pub async fn query_objects(&self, prototype_handle: &JSHandle) -> Result<JSHandle, BridgeError> {
362        self.remote.call("queryObjects", vec![Some(prototype_handle.remote().to_wire())]).await
363    }
364
365    /// `Page.$eval`
366    ///
367    /// ```text
368    /// $eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<NodeFor<Selector>, Params> = EvaluateFuncWith<NodeFor<Selector>, Params >>(selector: Selector, pageFunction: Func | string, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
369    /// ```
370    pub async fn eval_on_selector(&self, selector: &str, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
371        let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector)), Some(page_function.into().to_wire())];
372        call_args.extend(args.iter().map(|v| Some(v.clone())));
373        self.remote.call("$eval", call_args).await
374    }
375
376    /// `Page.$$eval`
377    ///
378    /// ```text
379    /// $$eval<Selector extends string, Params extends unknown[], Func extends EvaluateFuncWith<Array<NodeFor<Selector>>, Params> = EvaluateFuncWith<Array<NodeFor<Selector>>, Params>>(selector: Selector, pageFunction: Func | string, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
380    /// ```
381    pub async fn eval_on_selector_all(&self, selector: &str, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
382        let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector)), Some(page_function.into().to_wire())];
383        call_args.extend(args.iter().map(|v| Some(v.clone())));
384        self.remote.call("$$eval", call_args).await
385    }
386
387    /// `Page.cookies`
388    ///
389    /// ```text
390    /// cookies(...urls: string[]): Promise<Cookie[]>
391    /// ```
392    pub async fn cookies(&self, urls: &[&str]) -> Result<Vec<Value>, BridgeError> {
393        let mut call_args: Vec<Option<Value>> = vec![];
394        call_args.extend(urls.iter().map(|v| Some(Value::from(*v))));
395        self.remote.call("cookies", call_args).await
396    }
397
398    /// `Page.deleteCookie`
399    ///
400    /// ```text
401    /// deleteCookie(...cookies: DeleteCookiesRequest[]): Promise<void>
402    /// ```
403    pub async fn delete_cookie(&self, cookies: &[Value]) -> Result<(), BridgeError> {
404        let mut call_args: Vec<Option<Value>> = vec![];
405        call_args.extend(cookies.iter().map(|v| Some(v.clone())));
406        self.remote.call("deleteCookie", call_args).await
407    }
408
409    /// `Page.setCookie`
410    ///
411    /// ```text
412    /// setCookie(...cookies: CookieParam[]): Promise<void>
413    /// ```
414    pub async fn set_cookie(&self, cookies: &[Value]) -> Result<(), BridgeError> {
415        let mut call_args: Vec<Option<Value>> = vec![];
416        call_args.extend(cookies.iter().map(|v| Some(v.clone())));
417        self.remote.call("setCookie", call_args).await
418    }
419
420    /// `Page.addScriptTag`
421    ///
422    /// ```text
423    /// addScriptTag(options: FrameAddScriptTagOptions): Promise<ElementHandle<HTMLScriptElement>>
424    /// ```
425    pub async fn add_script_tag(&self, options: Value) -> Result<ElementHandle, BridgeError> {
426        self.remote.call("addScriptTag", vec![Some(options)]).await
427    }
428
429    /// `Page.addStyleTag`
430    ///
431    /// ```text
432    /// addStyleTag(options: Omit<FrameAddStyleTagOptions, 'url'>): Promise<ElementHandle<HTMLStyleElement>>
433    /// addStyleTag(options: FrameAddStyleTagOptions): Promise<ElementHandle<HTMLLinkElement>>
434    /// ```
435    pub async fn add_style_tag(&self, options: Value) -> Result<ElementHandle, BridgeError> {
436        self.remote.call("addStyleTag", vec![Some(options)]).await
437    }
438
439    /// `Page.exposeFunction`
440    ///
441    /// ```text
442    /// exposeFunction(name: string, pptrFunction: | Function | { default: Function; }): Promise<void>
443    /// ```
444    pub async fn expose_function(&self, name: &str, pptr_function: Value) -> Result<(), BridgeError> {
445        self.remote.call("exposeFunction", vec![Some(Value::from(name)), Some(pptr_function)]).await
446    }
447
448    /// `Page.removeExposedFunction`
449    ///
450    /// ```text
451    /// removeExposedFunction(name: string): Promise<void>
452    /// ```
453    pub async fn remove_exposed_function(&self, name: &str) -> Result<(), BridgeError> {
454        self.remote.call("removeExposedFunction", vec![Some(Value::from(name))]).await
455    }
456
457    /// `Page.authenticate`
458    ///
459    /// ```text
460    /// authenticate(credentials: Credentials | null): Promise<void>
461    /// ```
462    pub async fn authenticate(&self, credentials: Option<Value>) -> Result<(), BridgeError> {
463        self.remote.call("authenticate", vec![Some(credentials.unwrap_or(Value::Null))]).await
464    }
465
466    /// `Page.setExtraHTTPHeaders`
467    ///
468    /// ```text
469    /// setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>
470    /// ```
471    pub async fn set_extra_http_headers(&self, headers: Value) -> Result<(), BridgeError> {
472        self.remote.call("setExtraHTTPHeaders", vec![Some(headers)]).await
473    }
474
475    /// `Page.setUserAgent`
476    ///
477    /// ```text
478    /// setUserAgent(userAgent: string, userAgentMetadata?: Protocol.Emulation.UserAgentMetadata): Promise<void>
479    /// setUserAgent(options: { userAgent?: string; userAgentMetadata?: Protocol.Emulation.UserAgentMetadata; platform?: string; }): Promise<void>
480    /// ```
481    pub async fn set_user_agent(&self, user_agent: Value, user_agent_metadata: Option<Value>) -> Result<(), BridgeError> {
482        self.remote.call("setUserAgent", vec![Some(user_agent), user_agent_metadata]).await
483    }
484
485    /// `Page.metrics`
486    ///
487    /// ```text
488    /// metrics(): Promise<Metrics>
489    /// ```
490    pub async fn metrics(&self) -> Result<Value, BridgeError> {
491        self.remote.call("metrics", vec![]).await
492    }
493
494    /// `Page.captureHeapSnapshot`
495    ///
496    /// ```text
497    /// captureHeapSnapshot(options: HeapSnapshotOptions): Promise<void>
498    /// ```
499    pub async fn capture_heap_snapshot(&self, options: Value) -> Result<(), BridgeError> {
500        self.remote.call("captureHeapSnapshot", vec![Some(options)]).await
501    }
502
503    /// `Page.url`
504    ///
505    /// ```text
506    /// url(): string
507    /// ```
508    pub async fn url(&self) -> Result<String, BridgeError> {
509        self.remote.call("url", vec![]).await
510    }
511
512    /// `Page.content`
513    ///
514    /// ```text
515    /// content(): Promise<string>
516    /// ```
517    pub async fn content(&self) -> Result<String, BridgeError> {
518        self.remote.call("content", vec![]).await
519    }
520
521    /// `Page.setContent`
522    ///
523    /// ```text
524    /// setContent(html: string, options?: SetContentWaitForOptions): Promise<void>
525    /// ```
526    pub async fn set_content(&self, html: &str, options: Option<Value>) -> Result<(), BridgeError> {
527        self.remote.call("setContent", vec![Some(Value::from(html)), options]).await
528    }
529
530    /// `Page.goto`
531    ///
532    /// ```text
533    /// goto(url: string, options?: GoToOptions): Promise<HTTPResponse | null>
534    /// ```
535    pub async fn goto(&self, url: &str, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
536        self.remote.call("goto", vec![Some(Value::from(url)), options]).await
537    }
538
539    /// `Page.reload`
540    ///
541    /// ```text
542    /// reload(options?: ReloadOptions): Promise<HTTPResponse | null>
543    /// ```
544    pub async fn reload(&self, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
545        self.remote.call("reload", vec![options]).await
546    }
547
548    /// `Page.waitForNavigation`
549    ///
550    /// ```text
551    /// waitForNavigation(options?: WaitForOptions): Promise<HTTPResponse | null>
552    /// ```
553    pub async fn wait_for_navigation(&self, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
554        self.remote.call("waitForNavigation", vec![options]).await
555    }
556
557    /// `Page.waitForRequest`
558    ///
559    /// ```text
560    /// waitForRequest(urlOrPredicate: string | AwaitablePredicate<HTTPRequest>, options?: WaitTimeoutOptions): Promise<HTTPRequest>
561    /// ```
562    pub async fn wait_for_request(&self, url_or_predicate: impl Into<JsFunction>, options: Option<Value>) -> Result<HTTPRequest, BridgeError> {
563        self.remote.call("waitForRequest", vec![Some(url_or_predicate.into().to_wire()), options]).await
564    }
565
566    /// `Page.waitForResponse`
567    ///
568    /// ```text
569    /// waitForResponse(urlOrPredicate: string | AwaitablePredicate<HTTPResponse>, options?: WaitTimeoutOptions): Promise<HTTPResponse>
570    /// ```
571    pub async fn wait_for_response(&self, url_or_predicate: impl Into<JsFunction>, options: Option<Value>) -> Result<HTTPResponse, BridgeError> {
572        self.remote.call("waitForResponse", vec![Some(url_or_predicate.into().to_wire()), options]).await
573    }
574
575    /// `Page.waitForNetworkIdle`
576    ///
577    /// ```text
578    /// waitForNetworkIdle(options?: WaitForNetworkIdleOptions): Promise<void>
579    /// ```
580    pub async fn wait_for_network_idle(&self, options: Option<Value>) -> Result<(), BridgeError> {
581        self.remote.call("waitForNetworkIdle", vec![options]).await
582    }
583
584    /// `Page.waitForFrame`
585    ///
586    /// ```text
587    /// waitForFrame(urlOrPredicate: string | ((frame: Frame) => Awaitable<boolean>), options?: WaitTimeoutOptions): Promise<Frame>
588    /// ```
589    pub async fn wait_for_frame(&self, url_or_predicate: impl Into<JsFunction>, options: Option<Value>) -> Result<Frame, BridgeError> {
590        self.remote.call("waitForFrame", vec![Some(url_or_predicate.into().to_wire()), options]).await
591    }
592
593    /// `Page.goBack`
594    ///
595    /// ```text
596    /// goBack(options?: WaitForOptions): Promise<HTTPResponse | null>
597    /// ```
598    pub async fn go_back(&self, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
599        self.remote.call("goBack", vec![options]).await
600    }
601
602    /// `Page.goForward`
603    ///
604    /// ```text
605    /// goForward(options?: WaitForOptions): Promise<HTTPResponse | null>
606    /// ```
607    pub async fn go_forward(&self, options: Option<Value>) -> Result<Option<HTTPResponse>, BridgeError> {
608        self.remote.call("goForward", vec![options]).await
609    }
610
611    /// `Page.bringToFront`
612    ///
613    /// ```text
614    /// bringToFront(): Promise<void>
615    /// ```
616    pub async fn bring_to_front(&self) -> Result<(), BridgeError> {
617        self.remote.call("bringToFront", vec![]).await
618    }
619
620    /// `Page.emulate`
621    ///
622    /// ```text
623    /// emulate(device: Device): Promise<void>
624    /// ```
625    pub async fn emulate(&self, device: Value) -> Result<(), BridgeError> {
626        self.remote.call("emulate", vec![Some(device)]).await
627    }
628
629    /// `Page.setJavaScriptEnabled`
630    ///
631    /// ```text
632    /// setJavaScriptEnabled(enabled: boolean): Promise<void>
633    /// ```
634    pub async fn set_java_script_enabled(&self, enabled: bool) -> Result<(), BridgeError> {
635        self.remote.call("setJavaScriptEnabled", vec![Some(Value::from(enabled))]).await
636    }
637
638    /// `Page.setBypassCSP`
639    ///
640    /// ```text
641    /// setBypassCSP(enabled: boolean): Promise<void>
642    /// ```
643    pub async fn set_bypass_csp(&self, enabled: bool) -> Result<(), BridgeError> {
644        self.remote.call("setBypassCSP", vec![Some(Value::from(enabled))]).await
645    }
646
647    /// `Page.emulateMediaType`
648    ///
649    /// ```text
650    /// emulateMediaType(type?: string): Promise<void>
651    /// ```
652    pub async fn emulate_media_type(&self, type_: Option<&str>) -> Result<(), BridgeError> {
653        self.remote.call("emulateMediaType", vec![type_.map(|x| Value::from(x))]).await
654    }
655
656    /// `Page.emulateCPUThrottling`
657    ///
658    /// ```text
659    /// emulateCPUThrottling(factor: number | null): Promise<void>
660    /// ```
661    pub async fn emulate_cpu_throttling(&self, factor: Option<f64>) -> Result<(), BridgeError> {
662        self.remote.call("emulateCPUThrottling", vec![Some(factor.map(|x| Value::from(x)).unwrap_or(Value::Null))]).await
663    }
664
665    /// `Page.emulateMediaFeatures`
666    ///
667    /// ```text
668    /// emulateMediaFeatures(features?: MediaFeature[]): Promise<void>
669    /// ```
670    pub async fn emulate_media_features(&self, features: Option<Vec<Value>>) -> Result<(), BridgeError> {
671        self.remote.call("emulateMediaFeatures", vec![features.map(|x| Value::Array(x))]).await
672    }
673
674    /// `Page.emulateLocale`
675    ///
676    /// ```text
677    /// emulateLocale(locale?: string): Promise<void>
678    /// ```
679    pub async fn emulate_locale(&self, locale: Option<&str>) -> Result<(), BridgeError> {
680        self.remote.call("emulateLocale", vec![locale.map(|x| Value::from(x))]).await
681    }
682
683    /// `Page.emulateTimezone`
684    ///
685    /// ```text
686    /// emulateTimezone(timezoneId?: string): Promise<void>
687    /// ```
688    pub async fn emulate_timezone(&self, timezone_id: Option<&str>) -> Result<(), BridgeError> {
689        self.remote.call("emulateTimezone", vec![timezone_id.map(|x| Value::from(x))]).await
690    }
691
692    /// `Page.emulateIdleState`
693    ///
694    /// ```text
695    /// emulateIdleState(overrides?: { isUserActive: boolean; isScreenUnlocked: boolean; }): Promise<void>
696    /// ```
697    pub async fn emulate_idle_state(&self, overrides: Option<Value>) -> Result<(), BridgeError> {
698        self.remote.call("emulateIdleState", vec![overrides]).await
699    }
700
701    /// `Page.emulateVisionDeficiency`
702    ///
703    /// ```text
704    /// emulateVisionDeficiency(type?: Protocol.Emulation.SetEmulatedVisionDeficiencyRequest['type']): Promise<void>
705    /// ```
706    pub async fn emulate_vision_deficiency(&self, type_: Option<Value>) -> Result<(), BridgeError> {
707        self.remote.call("emulateVisionDeficiency", vec![type_]).await
708    }
709
710    /// `Page.setViewport`
711    ///
712    /// ```text
713    /// setViewport(viewport: Viewport | null): Promise<void>
714    /// ```
715    pub async fn set_viewport(&self, viewport: Option<Value>) -> Result<(), BridgeError> {
716        self.remote.call("setViewport", vec![Some(viewport.unwrap_or(Value::Null))]).await
717    }
718
719    /// `Page.viewport`
720    ///
721    /// ```text
722    /// viewport(): Viewport | null
723    /// ```
724    pub async fn viewport(&self) -> Result<Option<Value>, BridgeError> {
725        self.remote.call("viewport", vec![]).await
726    }
727
728    /// `Page.evaluate`
729    ///
730    /// ```text
731    /// evaluate<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, ...args: Params ): Promise<Awaited<ReturnType<Func>>>
732    /// ```
733    pub async fn evaluate(&self, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
734        let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire())];
735        call_args.extend(args.iter().map(|v| Some(v.clone())));
736        self.remote.call("evaluate", call_args).await
737    }
738
739    /// `Page.evaluateOnNewDocument`
740    ///
741    /// ```text
742    /// evaluateOnNewDocument<Params extends unknown[], Func extends (...args: Params) => unknown = (...args: Params) => unknown>(pageFunction: Func | string, ...args: Params ): Promise<NewDocumentScriptEvaluation>
743    /// ```
744    pub async fn evaluate_on_new_document(&self, page_function: impl Into<JsFunction>, args: &[Value]) -> Result<Value, BridgeError> {
745        let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire())];
746        call_args.extend(args.iter().map(|v| Some(v.clone())));
747        self.remote.call("evaluateOnNewDocument", call_args).await
748    }
749
750    /// `Page.removeScriptToEvaluateOnNewDocument`
751    ///
752    /// ```text
753    /// removeScriptToEvaluateOnNewDocument(identifier: string): Promise<void>
754    /// ```
755    pub async fn remove_script_to_evaluate_on_new_document(&self, identifier: &str) -> Result<(), BridgeError> {
756        self.remote.call("removeScriptToEvaluateOnNewDocument", vec![Some(Value::from(identifier))]).await
757    }
758
759    /// `Page.setCacheEnabled`
760    ///
761    /// ```text
762    /// setCacheEnabled(enabled?: boolean): Promise<void>
763    /// ```
764    pub async fn set_cache_enabled(&self, enabled: Option<bool>) -> Result<(), BridgeError> {
765        self.remote.call("setCacheEnabled", vec![enabled.map(|x| Value::from(x))]).await
766    }
767
768    /// `Page.screencast`
769    ///
770    /// ```text
771    /// screencast(options?: Readonly<ScreencastOptions>): Promise<ScreenRecorder>
772    /// ```
773    pub async fn screencast(&self, options: Option<Value>) -> Result<ScreenRecorder, BridgeError> {
774        self.remote.call("screencast", vec![options]).await
775    }
776
777    /// `Page.record`
778    ///
779    /// ```text
780    /// record(options?: Readonly<RecordOptions>): Promise<ScreenRecording>
781    /// ```
782    pub async fn record(&self, options: Option<Value>) -> Result<ScreenRecording, BridgeError> {
783        self.remote.call("record", vec![options]).await
784    }
785
786    /// `Page.screenshot`
787    ///
788    /// ```text
789    /// screenshot(options: Readonly<ScreenshotOptions> & { encoding: 'base64'; }): Promise<string>
790    /// screenshot(options?: Readonly<ScreenshotOptions>): Promise<Uint8Array>
791    /// ```
792    pub async fn screenshot(&self, options: Option<Value>) -> Result<Value, BridgeError> {
793        self.remote.call("screenshot", vec![options]).await
794    }
795
796    /// `Page.emulateFocusedPage`
797    ///
798    /// ```text
799    /// emulateFocusedPage(enabled: boolean): Promise<void>
800    /// ```
801    pub async fn emulate_focused_page(&self, enabled: bool) -> Result<(), BridgeError> {
802        self.remote.call("emulateFocusedPage", vec![Some(Value::from(enabled))]).await
803    }
804
805    /// `Page.createPDFStream`
806    ///
807    /// ```text
808    /// createPDFStream(options?: PDFOptions): Promise<ReadableStream<Uint8Array>>
809    /// ```
810    pub async fn create_pdf_stream(&self, options: Option<Value>) -> Result<Value, BridgeError> {
811        self.remote.call("createPDFStream", vec![options]).await
812    }
813
814    /// `Page.pdf`
815    ///
816    /// ```text
817    /// pdf(options?: PDFOptions): Promise<Uint8Array>
818    /// ```
819    pub async fn pdf(&self, options: Option<Value>) -> Result<Vec<u8>, BridgeError> {
820        self.remote.call("pdf", vec![options]).await
821    }
822
823    /// `Page.title`
824    ///
825    /// ```text
826    /// title(): Promise<string>
827    /// ```
828    pub async fn title(&self) -> Result<String, BridgeError> {
829        self.remote.call("title", vec![]).await
830    }
831
832    /// `Page.close`
833    ///
834    /// ```text
835    /// close(options?: {runBeforeUnload?: boolean}): Promise<void>
836    /// ```
837    pub async fn close(&self, options: Option<Value>) -> Result<(), BridgeError> {
838        self.remote.call("close", vec![options]).await
839    }
840
841    /// `Page.isClosed`
842    ///
843    /// ```text
844    /// isClosed(): boolean
845    /// ```
846    pub async fn is_closed(&self) -> Result<bool, BridgeError> {
847        self.remote.call("isClosed", vec![]).await
848    }
849
850    /// `Page.mouse`
851    ///
852    /// ```text
853    /// get mouse(): Mouse
854    /// ```
855    pub async fn mouse(&self) -> Result<Mouse, BridgeError> {
856        self.remote.get("mouse").await
857    }
858
859    /// `Page.click`
860    ///
861    /// ```text
862    /// click(selector: string, options?: Readonly<ClickOptions>): Promise<void>
863    /// ```
864    pub async fn click(&self, selector: &str, options: Option<Value>) -> Result<(), BridgeError> {
865        self.remote.call("click", vec![Some(Value::from(selector)), options]).await
866    }
867
868    /// `Page.focus`
869    ///
870    /// ```text
871    /// focus(selector: string): Promise<void>
872    /// ```
873    pub async fn focus(&self, selector: &str) -> Result<(), BridgeError> {
874        self.remote.call("focus", vec![Some(Value::from(selector))]).await
875    }
876
877    /// `Page.hover`
878    ///
879    /// ```text
880    /// hover(selector: string): Promise<void>
881    /// ```
882    pub async fn hover(&self, selector: &str) -> Result<(), BridgeError> {
883        self.remote.call("hover", vec![Some(Value::from(selector))]).await
884    }
885
886    /// `Page.select`
887    ///
888    /// ```text
889    /// select(selector: string, ...values: string[]): Promise<string[]>
890    /// ```
891    pub async fn select(&self, selector: &str, values: &[&str]) -> Result<Vec<String>, BridgeError> {
892        let mut call_args: Vec<Option<Value>> = vec![Some(Value::from(selector))];
893        call_args.extend(values.iter().map(|v| Some(Value::from(*v))));
894        self.remote.call("select", call_args).await
895    }
896
897    /// `Page.tap`
898    ///
899    /// ```text
900    /// tap(selector: string): Promise<void>
901    /// ```
902    pub async fn tap(&self, selector: &str) -> Result<(), BridgeError> {
903        self.remote.call("tap", vec![Some(Value::from(selector))]).await
904    }
905
906    /// `Page.type`
907    ///
908    /// ```text
909    /// type(selector: string, text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>
910    /// ```
911    pub async fn r#type(&self, selector: &str, text: &str, options: Option<Value>) -> Result<(), BridgeError> {
912        self.remote.call("type", vec![Some(Value::from(selector)), Some(Value::from(text)), options]).await
913    }
914
915    /// `Page.waitForSelector`
916    ///
917    /// ```text
918    /// waitForSelector<Selector extends string>(selector: Selector, options?: WaitForSelectorOptions): Promise<ElementHandle<NodeFor<Selector>> | null>
919    /// ```
920    pub async fn wait_for_selector(&self, selector: &str, options: Option<Value>) -> Result<Option<ElementHandle>, BridgeError> {
921        self.remote.call("waitForSelector", vec![Some(Value::from(selector)), options]).await
922    }
923
924    /// `Page.waitForFunction`
925    ///
926    /// ```text
927    /// waitForFunction<Params extends unknown[], Func extends EvaluateFunc<Params> = EvaluateFunc<Params>>(pageFunction: Func | string, options?: FrameWaitForFunctionOptions, ...args: Params ): Promise<HandleFor<Awaited<ReturnType<Func>>>>
928    /// ```
929    pub async fn wait_for_function(&self, page_function: impl Into<JsFunction>, options: Option<Value>, args: &[Value]) -> Result<JSHandle, BridgeError> {
930        let mut call_args: Vec<Option<Value>> = vec![Some(page_function.into().to_wire()), options];
931        call_args.extend(args.iter().map(|v| Some(v.clone())));
932        self.remote.call("waitForFunction", call_args).await
933    }
934
935    /// `Page.waitForDevicePrompt`
936    ///
937    /// ```text
938    /// waitForDevicePrompt(options?: WaitTimeoutOptions): Promise<DeviceRequestPrompt>
939    /// ```
940    pub async fn wait_for_device_prompt(&self, options: Option<Value>) -> Result<DeviceRequestPrompt, BridgeError> {
941        self.remote.call("waitForDevicePrompt", vec![options]).await
942    }
943}