click method

  1. @override
Future<Null> click({
  1. ClickOption? clickOption,
})
override

Clicks on the element with clickOption. clickOption is only used for HTML.

Implementation

@override
Future<Null> click({ClickOption? clickOption}) async {
  if (clickOption != null) {
    throw UnsupportedError(
        'WebDriver click() does not support `clickOption` parameter.');
  }

  if (!displayed) {
    await scrollIntoViewCentered();
  }

  // If the click fails because of ElementClickInterceptedException, it may be
  // because the element is not within viewport.
  // So we can try again after moving the element into the center of page.
  try {
    _retryWhenStale<void>(() => _single.click());
  } catch (ElementClickInterceptedException) {
    await scrollIntoViewCentered();
    _retryWhenStale<void>(() => _single.click());
  }
}