Skip to main content

browser_commander/puppeteer/api/
mouse.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 `Mouse` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    Mouse
15);
16
17impl Mouse {
18    /// `Mouse.reset`
19    ///
20    /// ```text
21    /// reset(): Promise<void>
22    /// ```
23    pub async fn reset(&self) -> Result<(), BridgeError> {
24        self.remote.call("reset", vec![]).await
25    }
26
27    /// `Mouse.move`
28    ///
29    /// ```text
30    /// move(x: number, y: number, options?: Readonly<MouseMoveOptions>): Promise<void>
31    /// ```
32    pub async fn r#move(&self, x: f64, y: f64, options: Option<Value>) -> Result<(), BridgeError> {
33        self.remote.call("move", vec![Some(Value::from(x)), Some(Value::from(y)), options]).await
34    }
35
36    /// `Mouse.down`
37    ///
38    /// ```text
39    /// down(options?: Readonly<MouseOptions>): Promise<void>
40    /// ```
41    pub async fn down(&self, options: Option<Value>) -> Result<(), BridgeError> {
42        self.remote.call("down", vec![options]).await
43    }
44
45    /// `Mouse.up`
46    ///
47    /// ```text
48    /// up(options?: Readonly<MouseOptions>): Promise<void>
49    /// ```
50    pub async fn up(&self, options: Option<Value>) -> Result<(), BridgeError> {
51        self.remote.call("up", vec![options]).await
52    }
53
54    /// `Mouse.click`
55    ///
56    /// ```text
57    /// click(x: number, y: number, options?: Readonly<MouseClickOptions>): Promise<void>
58    /// ```
59    pub async fn click(&self, x: f64, y: f64, options: Option<Value>) -> Result<(), BridgeError> {
60        self.remote.call("click", vec![Some(Value::from(x)), Some(Value::from(y)), options]).await
61    }
62
63    /// `Mouse.wheel`
64    ///
65    /// ```text
66    /// wheel(options?: Readonly<MouseWheelOptions>): Promise<void>
67    /// ```
68    pub async fn wheel(&self, options: Option<Value>) -> Result<(), BridgeError> {
69        self.remote.call("wheel", vec![options]).await
70    }
71
72    /// `Mouse.drag`
73    ///
74    /// ```text
75    /// drag(start: Point, target: Point): Promise<Protocol.Input.DragData>
76    /// ```
77    pub async fn drag(&self, start: Value, target: Value) -> Result<Value, BridgeError> {
78        self.remote.call("drag", vec![Some(start), Some(target)]).await
79    }
80
81    /// `Mouse.dragEnter`
82    ///
83    /// ```text
84    /// dragEnter(target: Point, data: Protocol.Input.DragData): Promise<void>
85    /// ```
86    pub async fn drag_enter(&self, target: Value, data: Value) -> Result<(), BridgeError> {
87        self.remote.call("dragEnter", vec![Some(target), Some(data)]).await
88    }
89
90    /// `Mouse.dragOver`
91    ///
92    /// ```text
93    /// dragOver(target: Point, data: Protocol.Input.DragData): Promise<void>
94    /// ```
95    pub async fn drag_over(&self, target: Value, data: Value) -> Result<(), BridgeError> {
96        self.remote.call("dragOver", vec![Some(target), Some(data)]).await
97    }
98
99    /// `Mouse.drop`
100    ///
101    /// ```text
102    /// drop(target: Point, data: Protocol.Input.DragData): Promise<void>
103    /// ```
104    pub async fn drop(&self, target: Value, data: Value) -> Result<(), BridgeError> {
105        self.remote.call("drop", vec![Some(target), Some(data)]).await
106    }
107
108    /// `Mouse.dragAndDrop`
109    ///
110    /// ```text
111    /// dragAndDrop(start: Point, target: Point, options?: { delay?: number; }): Promise<void>
112    /// ```
113    pub async fn drag_and_drop(&self, start: Value, target: Value, options: Option<Value>) -> Result<(), BridgeError> {
114        self.remote.call("dragAndDrop", vec![Some(start), Some(target), options]).await
115    }
116}