browser-commander 0.16.0

Universal browser automation library that supports multiple browser engines with a unified API
Documentation
// @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 `Dialog` (puppeteer-core 25.10.0), a remote object
    /// served by `browser-commander serve --stdio`.
    Dialog
);

impl Dialog {
    /// `Dialog.handled`
    ///
    /// ```text
    /// get handled(): boolean
    /// ```
    pub async fn handled(&self) -> Result<bool, BridgeError> {
        self.remote.get("handled").await
    }

    /// `Dialog.type`
    ///
    /// ```text
    /// type(): Protocol.Page.DialogType
    /// ```
    pub async fn r#type(&self) -> Result<Value, BridgeError> {
        self.remote.call("type", vec![]).await
    }

    /// `Dialog.message`
    ///
    /// ```text
    /// message(): string
    /// ```
    pub async fn message(&self) -> Result<String, BridgeError> {
        self.remote.call("message", vec![]).await
    }

    /// `Dialog.defaultValue`
    ///
    /// ```text
    /// defaultValue(): string
    /// ```
    pub async fn default_value(&self) -> Result<String, BridgeError> {
        self.remote.call("defaultValue", vec![]).await
    }

    /// `Dialog.accept`
    ///
    /// ```text
    /// accept(promptText?: string): Promise<void>
    /// ```
    pub async fn accept(&self, prompt_text: Option<&str>) -> Result<(), BridgeError> {
        self.remote.call("accept", vec![prompt_text.map(|x| Value::from(x))]).await
    }

    /// `Dialog.dismiss`
    ///
    /// ```text
    /// dismiss(): Promise<void>
    /// ```
    pub async fn dismiss(&self) -> Result<(), BridgeError> {
        self.remote.call("dismiss", vec![]).await
    }
}