browser_commander/puppeteer/api/
mouse.rs1#![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 Mouse
15);
16
17impl Mouse {
18 pub async fn reset(&self) -> Result<(), BridgeError> {
24 self.remote.call("reset", vec![]).await
25 }
26
27 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 pub async fn down(&self, options: Option<Value>) -> Result<(), BridgeError> {
42 self.remote.call("down", vec![options]).await
43 }
44
45 pub async fn up(&self, options: Option<Value>) -> Result<(), BridgeError> {
51 self.remote.call("up", vec![options]).await
52 }
53
54 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 pub async fn wheel(&self, options: Option<Value>) -> Result<(), BridgeError> {
69 self.remote.call("wheel", vec![options]).await
70 }
71
72 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 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 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 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 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}