selectWhereUntil method

Future<UITestChainNode<U, List<Element>, T>> selectWhereUntil(
  1. String? selectors,
  2. bool test(
    1. Element element
    ), {
  3. int? timeoutMs,
  4. int? intervalMs,
  5. int? minMs,
  6. Iterable<Element> mapper(
    1. List<Element> elems
    )?,
  7. bool expected = false,
})

Alias to sleepUntilElement + querySelectorAll + where.

Implementation

Future<UITestChainNode<U, List<Element>, T>> selectWhereUntil(
  String? selectors,
  bool Function(Element element) test, {
  int? timeoutMs,
  int? intervalMs,
  int? minMs,
  Iterable<Element> Function(List<Element> elems)? mapper,
  bool expected = false,
}) =>
    sleepUntilElement(
      selectors ?? '*',
      timeoutMs: timeoutMs,
      intervalMs: intervalMs,
      minMs: minMs,
      mapper: mapper,
      validator: (elems) => elems.any(test),
    ).selectWhere(selectors, test).thenChain((o) {
      if (expected) {
        var sel = selectAll(
          selectors,
        ).element.map((e) => e.simplify()).toList();

        expect(
          o.element,
          pkg_test.isNotEmpty,
          reason: "Can't find any selected element: $selectors -> $sel",
        );
      }
      return o as UITestChainNode<U, List<Element>, T>;
    });