- since: v1.8
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 [property: 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();
// 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();
# 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()
# 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()
await Page.Mouse.MoveAsync(0, 0);
await Page.Mouse.DownAsync();
await Page.Mouse.MoveAsync(0, 100);
await Page.Mouse.MoveAsync(100, 100);
await Page.Mouse.MoveAsync(100, 0);
await Page.Mouse.MoveAsync(0, 0);
await Page.Mouse.UpAsync();
- since: v1.8
Shortcut for [method: Mouse.move
], [method: Mouse.down
], [method: Mouse.up
].
- since: v1.8
x
<[float]>
X coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
y
<[float]>
Y coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
- since: v1.8
- since: v1.8
- since: v1.8
- langs:
- alias-csharp: DblClickAsync
Shortcut for [method: Mouse.move
], [method: Mouse.down
], [method: Mouse.up
], [method: Mouse.down
] and
[method: Mouse.up
].
- since: v1.8
x
<[float]>
X coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
y
<[float]>
Y coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
- since: v1.8
- since: v1.8
Dispatches a mousedown
event.
- since: v1.8
- since: v1.8
- since: v1.8
Dispatches a mousemove
event.
- since: v1.8
x
<[float]>
X coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
y
<[float]>
Y coordinate relative to the main frame's viewport in CSS pixels.
- since: v1.8
steps
<[int]>
Defaults to 1. Sends intermediate mousemove
events.
- since: v1.8
Dispatches a mouseup
event.
- since: v1.8
- since: v1.8
- since: v1.15
Dispatches a wheel
event. This method is usually used to manually scroll the page. See scrolling for alternative ways to scroll.
:::note Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning. :::
- since: v1.15
deltaX
<[float]>
Pixels to scroll horizontally.
- since: v1.15
deltaY
<[float]>
Pixels to scroll vertically.