maybe_click method

Future<Online> maybe_click(
  1. AbstractSelector selector, {
  2. bool show = true,
  3. int index = 0,
})

Implementation

Future<Online> maybe_click(AbstractSelector selector,
    {bool show = true, int index = 0}) async {
  try {
    if (show) Show.action('clicking', selector.selector);
    var selected = selector is XPath
        ? await (await page).waitForXPath(selector.selector,
            visible: true, timeout: minimal_timeout)
        : await (await page).waitForSelector(selector.selector,
            visible: true, timeout: minimal_timeout);
    if (selected != null) {
      await selected.click();
    }
  } catch (e) {
    if (show) Show.error(e.toString());
  }
  return this;
}