Skip to main content
Version: 1.15

Mouse

The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.

Every page object has its own Mouse, accessible with Page.Mouse.

await Page.Mouse.MoveAsync(0, 0);await Page.Mouse.DownAsync();await Page.Mouse.MoveAsync(0, 100);await Page.Mouse.MoveAsync(100, 100);await Page.Mouse.MoveAsync(100, 0);await Page.Mouse.MoveAsync(0, 0);await Page.Mouse.UpAsync();

Mouse.ClickAsync(x, y, options)#

  • x <double>#
  • y <double>#
  • options <MouseClickOptions?>
    • Button <enum MouseButton { Left, Right, Middle }?> Defaults to left.#
    • ClickCount <int?> defaults to 1. See UIEvent.detail.#
    • Delay <double?> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.#
  • returns: <void>#

Shortcut for Mouse.MoveAsync(x, y, options), Mouse.DownAsync(options), Mouse.UpAsync(options).

Mouse.DblClickAsync(x, y, options)#

  • x <double>#
  • y <double>#
  • options <MouseDblClickOptions?>
    • Button <enum MouseButton { Left, Right, Middle }?> Defaults to left.#
    • Delay <double?> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.#
  • returns: <void>#

Shortcut for Mouse.MoveAsync(x, y, options), Mouse.DownAsync(options), Mouse.UpAsync(options), Mouse.DownAsync(options) and Mouse.UpAsync(options).

Mouse.DownAsync(options)#

  • options <MouseDownOptions?>
    • Button <enum MouseButton { Left, Right, Middle }?> Defaults to left.#
    • ClickCount <int?> defaults to 1. See UIEvent.detail.#
  • returns: <void>#

Dispatches a mousedown event.

Mouse.MoveAsync(x, y, options)#

  • x <double>#
  • y <double>#
  • options <MouseMoveOptions?>
    • Steps <int?> defaults to 1. Sends intermediate mousemove events.#
  • returns: <void>#

Dispatches a mousemove event.

Mouse.UpAsync(options)#

  • options <MouseUpOptions?>
    • Button <enum MouseButton { Left, Right, Middle }?> Defaults to left.#
    • ClickCount <int?> defaults to 1. See UIEvent.detail.#
  • returns: <void>#

Dispatches a mouseup event.

Mouse.WheelAsync(deltaX, deltaY)#

  • deltaX <double> Pixels to scroll horizontally.#
  • deltaY <double> Pixels to scroll vertically.#
  • returns: <void>#

Dispatches a wheel event.

note

Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.