class: 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.click(x, y[, options])
x
<number>y
<number>options
<Object>button
<”left”|”right”|”middle”> Defaults toleft
.clickCount
<number> defaults to 1. See UIEvent.detail.delay
<number> Time to wait betweenmousedown
andmouseup
in milliseconds. Defaults to 0.
- returns: <Promise>
Shortcut for mouse.move
, mouse.down
and mouse.up
.
mouse.dblclick(x, y[, options])
x
<number>y
<number>options
<Object>button
<”left”|”right”|”middle”> Defaults toleft
.delay
<number> Time to wait betweenmousedown
andmouseup
in milliseconds. Defaults to 0.
- returns: <Promise>
Shortcut for mouse.move
, mouse.down
, mouse.up
, mouse.down
and mouse.up
.
mouse.down([options])
options
<Object>button
<”left”|”right”|”middle”> Defaults toleft
.clickCount
<number> defaults to 1. See UIEvent.detail.
- returns: <Promise>
Dispatches a mousedown
event.
mouse.move(x, y[, options])
x
<number>y
<number>options
<Object>steps
<number> defaults to 1. Sends intermediatemousemove
events.
- returns: <Promise>
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>
Dispatches a mouseup
event.