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.

// Using ‘page.mouse’ to trace a 100x100 square.await page.mouse.move(0, 0);await page.mouse.down();await page.mouse.move(0, 100);await page.mouse.move(100, 100);await page.mouse.move(100, 0);await page.mouse.move(0, 0);await page.mouse.up();

mouse.click(x, y[, options])#

Shortcut for mouse.move(x, y[, options]), mouse.down([options]), mouse.up([options]).

mouse.dblclick(x, y[, options])#

  • x <number>#
  • y <number>#
  • options <Object>
    • button <"left"|"right"|"middle"> Defaults to left.#
    • delay <number> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.#
  • returns: <Promise<void>>#

Shortcut for mouse.move(x, y[, options]), mouse.down([options]), mouse.up([options]), mouse.down([options]) and mouse.up([options]).

mouse.down([options])#

Dispatches a mousedown event.

mouse.move(x, y[, options])#

Dispatches a mousemove event.

mouse.up([options])#

Dispatches a mouseup event.

mouse.wheel(deltaX, deltaY)#

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.