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])
- mouse.dblclick(x, y[, options])
- mouse.down([options])
- mouse.move(x, y[, options])
- mouse.up([options])
- mouse.wheel(deltaX, deltaY)
#
mouse.click(x, y[, options])Shortcut for mouse.move(x, y[, options]), mouse.down([options]), mouse.up([options]).
#
mouse.dblclick(x, y[, options])Shortcut for mouse.move(x, y[, options]), mouse.down([options]), mouse.up([options]), mouse.down([options]) and mouse.up([options]).
#
mouse.down([options])options
<Object>button
<"left"|"right"|"middle"> Defaults toleft
.#clickCount
<number> defaults to 1. See UIEvent.detail.#
- returns:Promise<void>># <
Dispatches a mousedown
event.
#
mouse.move(x, y[, options])Dispatches a mousemove
event.
#
mouse.up([options])options
<Object>button
<"left"|"right"|"middle"> Defaults toleft
.#clickCount
<number> defaults to 1. See UIEvent.detail.#
- returns:Promise<void>># <
Dispatches a mouseup
event.
#
mouse.wheel(deltaX, deltaY)deltaX
<number> Pixels to scroll horizontally.#deltaY
<number> Pixels to scroll vertically.#- returns:Promise<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.