Version: 1.8.0

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.

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.

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

mouse.down(**kwargs)#

  • button <"left"|"right"|"middle"> Defaults to left.
  • click_count <int> defaults to 1. See UIEvent.detail.

Dispatches a mousedown event.

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

  • x <float>
  • y <float>
  • steps <int> defaults to 1. Sends intermediate mousemove events.

Dispatches a mousemove event.

mouse.up(**kwargs)#

  • button <"left"|"right"|"middle"> Defaults to left.
  • click_count <int> defaults to 1. See UIEvent.detail.

Dispatches a mouseup event.