Interface 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.

// 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

  • Mouse

Methods

  • Parameters

    • x: number
    • y: number
    • Optional options: {
          button?: "left" | "right" | "middle";
          clickCount?: number;
          delay?: number;
      }
      Optional
      • Optional button?: "left" | "right" | "middle"

        Defaults to left.

      • Optional clickCount?: number

        defaults to 1. See [UIEvent.detail].

      • Optional delay?: number

        Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

    Returns Promise<void>

  • Parameters

    • x: number
    • y: number
    • Optional options: {
          button?: "left" | "right" | "middle";
          delay?: number;
      }
      Optional
      • Optional button?: "left" | "right" | "middle"

        Defaults to left.

      • Optional delay?: number

        Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

    Returns Promise<void>

  • Dispatches a mousedown event.

    Parameters

    • Optional options: {
          button?: "left" | "right" | "middle";
          clickCount?: number;
      }
      Optional
      • Optional button?: "left" | "right" | "middle"

        Defaults to left.

      • Optional clickCount?: number

        defaults to 1. See [UIEvent.detail].

    Returns Promise<void>

  • Dispatches a mousemove event.

    Parameters

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

        Defaults to 1. Sends intermediate mousemove events.

    Returns Promise<void>

  • Dispatches a mouseup event.

    Parameters

    • Optional options: {
          button?: "left" | "right" | "middle";
          clickCount?: number;
      }
      Optional
      • Optional button?: "left" | "right" | "middle"

        Defaults to left.

      • Optional clickCount?: number

        defaults to 1. See [UIEvent.detail].

    Returns Promise<void>

  • Dispatches a wheel event.

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

    Parameters

    • deltaX: number

      Pixels to scroll horizontally.

    • deltaY: number

      Pixels to scroll vertically.

    Returns Promise<void>

Generated using TypeDoc