selectFirstWhereUntil<O extends Element> method

Future<UITestChainNode<U, O, T>> selectFirstWhereUntil<O extends Element>(
  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
    )?,
})

Alias to sleepUntilElement + querySelectorAll + firstWhereOrNull.

Implementation

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

        expect(elem, pkg_test.isNotNull,
            reason: "Can't find selected element: $selectors -> $sel");
      }
      return UITestChainNode<U, O, T>(
          o.testChainRoot as UITestChainRoot<U>, elem!, this as T);
    });