Table of Contents

Interface IMouse

Namespace
Microsoft.Playwright
Assembly
Microsoft.Playwright.dll

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 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();
public interface IMouse

Methods

ClickAsync(float, float, MouseClickOptions?)

Task ClickAsync(float x, float y, MouseClickOptions? options = null)

Parameters

x float
y float
options MouseClickOptions

Call options

Returns

Task

DblClickAsync(float, float, MouseDblClickOptions?)

Task DblClickAsync(float x, float y, MouseDblClickOptions? options = null)

Parameters

x float
y float
options MouseDblClickOptions

Call options

Returns

Task

DownAsync(MouseDownOptions?)

Dispatches a mousedown event.

Task DownAsync(MouseDownOptions? options = null)

Parameters

options MouseDownOptions

Call options

Returns

Task

MoveAsync(float, float, MouseMoveOptions?)

Dispatches a mousemove event.

Task MoveAsync(float x, float y, MouseMoveOptions? options = null)

Parameters

x float
y float
options MouseMoveOptions

Call options

Returns

Task

UpAsync(MouseUpOptions?)

Dispatches a mouseup event.

Task UpAsync(MouseUpOptions? options = null)

Parameters

options MouseUpOptions

Call options

Returns

Task

WheelAsync(float, float)

Dispatches a wheel event. This method is usually used to manually scroll the page. See scrolling for alternative ways to scroll.

Task WheelAsync(float deltaX, float deltaY)

Parameters

deltaX float

Pixels to scroll horizontally.

deltaY float

Pixels to scroll vertically.

Returns

Task

Remarks

Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.