Skip to main content

browser_commander/puppeteer/api/
dialog.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 `Dialog` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    Dialog
15);
16
17impl Dialog {
18    /// `Dialog.handled`
19    ///
20    /// ```text
21    /// get handled(): boolean
22    /// ```
23    pub async fn handled(&self) -> Result<bool, BridgeError> {
24        self.remote.get("handled").await
25    }
26
27    /// `Dialog.type`
28    ///
29    /// ```text
30    /// type(): Protocol.Page.DialogType
31    /// ```
32    pub async fn r#type(&self) -> Result<Value, BridgeError> {
33        self.remote.call("type", vec![]).await
34    }
35
36    /// `Dialog.message`
37    ///
38    /// ```text
39    /// message(): string
40    /// ```
41    pub async fn message(&self) -> Result<String, BridgeError> {
42        self.remote.call("message", vec![]).await
43    }
44
45    /// `Dialog.defaultValue`
46    ///
47    /// ```text
48    /// defaultValue(): string
49    /// ```
50    pub async fn default_value(&self) -> Result<String, BridgeError> {
51        self.remote.call("defaultValue", vec![]).await
52    }
53
54    /// `Dialog.accept`
55    ///
56    /// ```text
57    /// accept(promptText?: string): Promise<void>
58    /// ```
59    pub async fn accept(&self, prompt_text: Option<&str>) -> Result<(), BridgeError> {
60        self.remote.call("accept", vec![prompt_text.map(|x| Value::from(x))]).await
61    }
62
63    /// `Dialog.dismiss`
64    ///
65    /// ```text
66    /// dismiss(): Promise<void>
67    /// ```
68    pub async fn dismiss(&self) -> Result<(), BridgeError> {
69        self.remote.call("dismiss", vec![]).await
70    }
71}