foreach method

Future<Online> foreach(
  1. AbstractSelector selector,
  2. dynamic action(
    1. ElementHandle,
    2. Ctx
    )
)

foreach

Implementation

Future<Online> foreach(
    AbstractSelector selector, Function(ElementHandle, Ctx) action) async {
  await (await page).waitForSelector(selector.selector);
  var elements = await (await page).evaluate('''(selector) => {
    return Array.from(document.querySelectorAll(selector));
  }''', args: [selector.selector]);
  for (var element in elements) {
    await action(element, ctx);
  }
  return this;
}