Skip to main content
Version: 1.22

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.

# using ‘page.mouse’ to trace a 100x100 square.
page.mouse.move(0, 0)
page.mouse.down()
page.mouse.move(0, 100)
page.mouse.move(100, 100)
page.mouse.move(100, 0)
page.mouse.move(0, 0)
page.mouse.up()

mouse.click(x, y, **kwargs)

  • x <float>#
  • y <float>#
  • button <"left"|"right"|"middle"> Defaults to left.#
  • click_count <int> defaults to 1. See UIEvent.detail.#
  • delay <float> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.#
  • returns: <NoneType>#

Shortcut for mouse.move(x, y, **kwargs), mouse.down(**kwargs), mouse.up(**kwargs).

mouse.dblclick(x, y, **kwargs)

  • x <float>#
  • y <float>#
  • button <"left"|"right"|"middle"> Defaults to left.#
  • delay <float> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.#
  • returns: <NoneType>#

Shortcut for mouse.move(x, y, **kwargs), mouse.down(**kwargs), mouse.up(**kwargs), mouse.down(**kwargs) and mouse.up(**kwargs).

mouse.down(**kwargs)

Dispatches a mousedown event.

mouse.move(x, y, **kwargs)

Dispatches a mousemove event.

mouse.up(**kwargs)

Dispatches a mouseup event.

mouse.wheel(delta_x, delta_y)

  • delta_x <float> Pixels to scroll horizontally.#
  • delta_y <float> Pixels to scroll vertically.#
  • returns: <NoneType>#

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.