class: 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.

  1. // Using ‘page.mouse’ to trace a 100x100 square.
  2. await page.mouse.move(0, 0);
  3. await page.mouse.down();
  4. await page.mouse.move(0, 100);
  5. await page.mouse.move(100, 100);
  6. await page.mouse.move(100, 0);
  7. await page.mouse.move(0, 0);
  8. await page.mouse.up();

mouse.click(x, y[, options])

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

mouse.dblclick(x, y[, options])

  • x <number>
  • y <number>
  • options <Object>
    • button <”left”|”right”|”middle”> Defaults to left.
    • delay <number> Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.
  • returns: <Promise>

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

mouse.down([options])

Dispatches a mousedown event.

mouse.move(x, y[, options])

Dispatches a mousemove event.

mouse.up([options])

Dispatches a mouseup event.