click method

Future<void> click({
  1. Duration? delay,
  2. MouseButton? button,
  3. int? clickCount,
})

This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element. If the element is detached from DOM, the method throws an error.

Parameters:

  • button: Defaults to MouseButton.left
  • clickCount: Defaults to 1
  • delay: Time to wait between mousedown and mouseup. Defaults to 0.

Returns Future which resolves when the element is successfully clicked. Future gets rejected if the element is detached from DOM.

Implementation

Future<void> click(
    {Duration? delay, MouseButton? button, int? clickCount}) async {
  await _scrollIntoViewIfNeeded();
  var point = await _clickablePoint();
  await page.mouse
      .click(point, delay: delay, button: button, clickCount: clickCount);
}