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.
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();
Methods
ClickAsync
Added before v1.9Shortcut for Mouse.MoveAsync(), Mouse.DownAsync(), Mouse.UpAsync().
Usage
await Mouse.ClickAsync(x, y, options);
Arguments
-
x[float]#X coordinate relative to the main frame's viewport in CSS pixels.
-
y[float]#Y coordinate relative to the main frame's viewport in CSS pixels.
-
optionsMouseClickOptions?(optional)-
Buttonenum MouseButton { Left, Right, Middle }?(optional)#Defaults to
left. -
defaults to 1. See UIEvent.detail.
-
Delay[float]? (optional)#Time to wait between
mousedownandmouseupin milliseconds. Defaults to 0.
-
Returns
DblClickAsync
Added before v1.9Shortcut for Mouse.MoveAsync(), Mouse.DownAsync(), Mouse.UpAsync(), Mouse.DownAsync() and Mouse.UpAsync().
Usage
await Mouse.DblClickAsync(x, y, options);
Arguments
-
x[float]#X coordinate relative to the main frame's viewport in CSS pixels.
-
y[float]#Y coordinate relative to the main frame's viewport in CSS pixels.
-
optionsMouseDblClickOptions?(optional)
Returns
DownAsync
Added before v1.9Dispatches a mousedown event.
Usage
await Mouse.DownAsync(options);
Arguments
optionsMouseDownOptions?(optional)-
Buttonenum MouseButton { Left, Right, Middle }?(optional)#Defaults to
left. -
defaults to 1. See UIEvent.detail.
-
Returns
MoveAsync
Added before v1.9Dispatches a mousemove event.
Usage
await Mouse.MoveAsync(x, y, options);
Arguments
-
x[float]#X coordinate relative to the main frame's viewport in CSS pixels.
-
y[float]#Y coordinate relative to the main frame's viewport in CSS pixels.
-
optionsMouseMoveOptions?(optional)
Returns
UpAsync
Added before v1.9Dispatches a mouseup event.
Usage
await Mouse.UpAsync(options);
Arguments
optionsMouseUpOptions?(optional)-
Buttonenum MouseButton { Left, Right, Middle }?(optional)#Defaults to
left. -
defaults to 1. See UIEvent.detail.
-
Returns
WheelAsync
Added in: v1.15Dispatches a wheel event. This method is usually used to manually scroll the page. See scrolling for alternative ways to scroll.
Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.
Usage
await Mouse.WheelAsync(deltaX, deltaY);
Arguments
Returns