browser-commander 0.17.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 `Keyboard` (puppeteer-core 25.10.0), a remote object
    /// served by `browser-commander serve --stdio`.
    Keyboard
);

impl Keyboard {
    /// `Keyboard.down`
    ///
    /// ```text
    /// down(key: KeyInput, options?: Readonly<KeyDownOptions>): Promise<void>
    /// ```
    pub async fn down(&self, key: &str, options: Option<Value>) -> Result<(), BridgeError> {
        self.remote.call("down", vec![Some(Value::from(key)), options]).await
    }

    /// `Keyboard.up`
    ///
    /// ```text
    /// up(key: KeyInput): Promise<void>
    /// ```
    pub async fn up(&self, key: &str) -> Result<(), BridgeError> {
        self.remote.call("up", vec![Some(Value::from(key))]).await
    }

    /// `Keyboard.sendCharacter`
    ///
    /// ```text
    /// sendCharacter(char: string): Promise<void>
    /// ```
    pub async fn send_character(&self, char: &str) -> Result<(), BridgeError> {
        self.remote.call("sendCharacter", vec![Some(Value::from(char))]).await
    }

    /// `Keyboard.type`
    ///
    /// ```text
    /// type(text: string, options?: Readonly<KeyboardTypeOptions>): Promise<void>
    /// ```
    pub async fn r#type(&self, text: &str, options: Option<Value>) -> Result<(), BridgeError> {
        self.remote.call("type", vec![Some(Value::from(text)), options]).await
    }

    /// `Keyboard.press`
    ///
    /// ```text
    /// press(key: KeyInput, options?: Readonly<KeyPressOptions>): Promise<void>
    /// ```
    pub async fn press(&self, key: &str, options: Option<Value>) -> Result<(), BridgeError> {
        self.remote.call("press", vec![Some(Value::from(key)), options]).await
    }
}