Options
All
  • Public
  • Public/Protected
  • All
Menu

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();

Hierarchy

  • _PlatformObjBinding
    • Mouse

Index

Methods

Methods

click

  • click(x: number, y: number, options: ClickOptions): Promise<void>
    • x <number>
    • y <number>
    • options <Object>
    • button <"left"|"right"|"middle"< Defaults to left.
    • clickCount <number> defaults to 1. See UIEvent.detail.
    • delay <number> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.
    • returns: <Promise>

    Shortcut for mouse.move, mouse.down and mouse.up.

    Parameters

    Returns Promise<void>

down

    • options <Object>
    • button <"left"|"right"|"middle"< Defaults to left.
    • clickCount <number> defaults to 1. See UIEvent.detail.
    • returns: <Promise>

    Dispatches a mousedown event.

    Parameters

    Returns Promise<void>

move

  • move(x: number, y: number, options?: { steps: number }): Promise<void>
    • x <number>
    • y <number>
    • options <Object>
    • steps <number> defaults to 1. Sends intermediate mousemove events.
    • returns: <Promise>

    Dispatches a mousemove event.

    Parameters

    • x: number
    • y: number
    • Optional options: { steps: number }
      • steps: number

    Returns Promise<void>

up

    • options <Object>
    • button <"left"|"right"|"middle"< Defaults to left.
    • clickCount <number> defaults to 1. See UIEvent.detail.
    • returns: <Promise>

    Dispatches a mouseup event.

    Parameters

    Returns Promise<void>