Skip to main content

browser_commander/puppeteer/api/
target.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 `Target` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    Target
15);
16
17impl Target {
18    /// `Target.worker`
19    ///
20    /// ```text
21    /// worker(): Promise<WebWorker | null>
22    /// ```
23    pub async fn worker(&self) -> Result<Option<WebWorker>, BridgeError> {
24        self.remote.call("worker", vec![]).await
25    }
26
27    /// `Target.page`
28    ///
29    /// ```text
30    /// page(): Promise<Page | null>
31    /// ```
32    pub async fn page(&self) -> Result<Option<Page>, BridgeError> {
33        self.remote.call("page", vec![]).await
34    }
35
36    /// `Target.asPage`
37    ///
38    /// ```text
39    /// asPage(): Promise<Page>
40    /// ```
41    pub async fn as_page(&self) -> Result<Page, BridgeError> {
42        self.remote.call("asPage", vec![]).await
43    }
44
45    /// `Target.url`
46    ///
47    /// ```text
48    /// url(): string
49    /// ```
50    pub async fn url(&self) -> Result<String, BridgeError> {
51        self.remote.call("url", vec![]).await
52    }
53
54    /// `Target.createCDPSession`
55    ///
56    /// ```text
57    /// createCDPSession(): Promise<CDPSession>
58    /// ```
59    pub async fn create_cdp_session(&self) -> Result<CDPSession, BridgeError> {
60        self.remote.call("createCDPSession", vec![]).await
61    }
62
63    /// `Target.type`
64    ///
65    /// ```text
66    /// type(): TargetType
67    /// ```
68    pub async fn r#type(&self) -> Result<String, BridgeError> {
69        self.remote.call("type", vec![]).await
70    }
71
72    /// `Target.browser`
73    ///
74    /// ```text
75    /// browser(): Browser
76    /// ```
77    pub async fn browser(&self) -> Result<Browser, BridgeError> {
78        self.remote.call("browser", vec![]).await
79    }
80
81    /// `Target.browserContext`
82    ///
83    /// ```text
84    /// browserContext(): BrowserContext
85    /// ```
86    pub async fn browser_context(&self) -> Result<BrowserContext, BridgeError> {
87        self.remote.call("browserContext", vec![]).await
88    }
89
90    /// `Target.opener`
91    ///
92    /// ```text
93    /// opener(): Target | undefined
94    /// ```
95    pub async fn opener(&self) -> Result<Option<Target>, BridgeError> {
96        self.remote.call("opener", vec![]).await
97    }
98}