pub struct Mouse { /* private fields */ }Expand description
High-level helper for dispatching mouse input via the CDP Input domain.
Implementations§
Source§impl Mouse
impl Mouse
Sourcepub async fn move_to(&self, x: f64, y: f64) -> Result<MousePosition>
pub async fn move_to(&self, x: f64, y: f64) -> Result<MousePosition>
Moves the cursor to the given coordinates and returns the resolved position.
§Examples
let mouse = page.mouse();
let position = mouse.move_to(120.0, 80.0).await?;
assert_eq!(position.viewport_x, 120.0);Sourcepub async fn click(
&self,
x: f64,
y: f64,
options: MouseClickOptions,
) -> Result<()>
pub async fn click( &self, x: f64, y: f64, options: MouseClickOptions, ) -> Result<()>
Performs a single click at the provided coordinates.
§Examples
let mouse = page.mouse();
let mut options = MouseClickOptions::default();
options.button = MouseButton::Right;
mouse.click(300.0, 200.0, options).await?;Sourcepub async fn left_click(&self, x: f64, y: f64) -> Result<()>
pub async fn left_click(&self, x: f64, y: f64) -> Result<()>
Convenience helper for a left-button click.
Sourcepub async fn right_click(&self, x: f64, y: f64) -> Result<()>
pub async fn right_click(&self, x: f64, y: f64) -> Result<()>
Convenience helper for a right-button click.
Sourcepub async fn double_click(
&self,
x: f64,
y: f64,
options: DoubleClickOptions,
) -> Result<()>
pub async fn double_click( &self, x: f64, y: f64, options: DoubleClickOptions, ) -> Result<()>
Performs a double-click; the default delay is 50ms between presses.
Sourcepub async fn press_and_hold(
&self,
x: f64,
y: f64,
button: MouseButton,
duration: Duration,
) -> Result<()>
pub async fn press_and_hold( &self, x: f64, y: f64, button: MouseButton, duration: Duration, ) -> Result<()>
Holds the given button at the coordinates for the requested duration.
Sourcepub async fn press_and_hold_until<F, Fut>(
&self,
x: f64,
y: f64,
options: PressHoldOptions,
condition: F,
) -> Result<bool>
pub async fn press_and_hold_until<F, Fut>( &self, x: f64, y: f64, options: PressHoldOptions, condition: F, ) -> Result<bool>
Holds the given button until the condition callback returns true or a timeout occurs.
§Examples
let mouse = page.mouse();
let mut options = PressHoldOptions::default();
options.timeout = Some(Duration::from_secs(2));
let success = mouse
.press_and_hold_until(400.0, 250.0, options, || async { Ok(true) })
.await?;
assert!(success);Sourcepub async fn drag_to(
&self,
start_x: f64,
start_y: f64,
end_x: f64,
end_y: f64,
options: DragOptions,
) -> Result<()>
pub async fn drag_to( &self, start_x: f64, start_y: f64, end_x: f64, end_y: f64, options: DragOptions, ) -> Result<()>
Simulates drag gestures by generating a jittered, eased trajectory between two points.
§Examples
let mouse = page.mouse();
mouse.drag_to(20.0, 20.0, 220.0, 260.0, DragOptions::default()).await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mouse
impl !RefUnwindSafe for Mouse
impl Send for Mouse
impl Sync for Mouse
impl Unpin for Mouse
impl !UnwindSafe for Mouse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more