Skip to main content
The Mouse class provides methods to simulate mouse interactions such as moving, clicking, and scrolling. Access the Mouse instance through page.mouse.

Methods

move

Moves the mouse to the specified position.
await page.mouse.move(100, 200);
await page.mouse.move(150, 250, { steps: 5 });
x
number
required
The x coordinate to move to
y
number
required
The y coordinate to move to
options.steps
number
Number of intermediate steps to use when moving the mouse. Defaults to 1 (instant movement).

down

Presses a mouse button without releasing it.
await page.mouse.down();
await page.mouse.down({ button: 'right' });
options.button
'left' | 'right' | 'middle'
The button to press. Defaults to ‘left’.
options.clickCount
number
Number of times the button is clicked. Defaults to 1.

up

Releases a mouse button.
await page.mouse.up();
await page.mouse.up({ button: 'right' });
options.button
'left' | 'right' | 'middle'
The button to release. Defaults to ‘left’.
options.clickCount
number
Number of times the button is clicked. Defaults to 1.

click

Clicks at the specified position.
await page.mouse.click(100, 200);
await page.mouse.click(100, 200, { button: 'right', delay: 100 });
x
number
required
The x coordinate to click at
y
number
required
The y coordinate to click at
options.button
'left' | 'right' | 'middle'
The button to click. Defaults to ‘left’.
options.clickCount
number
Number of times to click. Defaults to 1.
options.delay
number
Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

dblclick

Double-clicks at the specified position.
await page.mouse.dblclick(100, 200);
await page.mouse.dblclick(100, 200, { delay: 100 });
x
number
required
The x coordinate to double-click at
y
number
required
The y coordinate to double-click at
options.button
'left' | 'right' | 'middle'
The button to click. Defaults to ‘left’.
options.delay
number
Time to wait between clicks in milliseconds. Defaults to 0.

wheel

Scrolls the page using the mouse wheel.
await page.mouse.wheel(0, 100);
await page.mouse.wheel(50, 200);
deltaX
number
required
Horizontal scroll amount in pixels
deltaY
number
required
Vertical scroll amount in pixels

Example Usage

Drag and Drop

await page.mouse.move(100, 100);
await page.mouse.down();
await page.mouse.move(200, 200, { steps: 5 });
await page.mouse.up();

Context Menu

await page.mouse.click(100, 100, { button: 'right' });

Scroll Page

await page.mouse.wheel(0, 500);

Build docs developers (and LLMs) love