testUISleepUntilElement function
Calls testUISleepUntil checking if root
has an UIElement
matching selectors
.
Implementation
Future<bool> testUISleepUntilElement(Object? root, String selectors,
{int? timeoutMs,
int? intervalMs,
int? minMs,
Iterable<UIElement> Function(List<UIElement> elems)? mapper,
bool Function(List<UIElement> elems)? validator,
bool expected = false}) {
root ??= document.documentElement;
if (root is! UIElement && root is! UIComponent) {
throw ArgumentError("`root` is not an `UIElement` or `UIComponent`");
}
var stackTrace = StackTrace.current;
return testUISleepUntil(
() => _existsElement(root, selectors, mapper, validator),
readyTitle: 'selectors: $selectors',
timeoutMs: timeoutMs ?? 2000,
intervalMs: intervalMs ?? 100,
minMs: minMs,
).thenChain((ok) {
if (expected && !ok) {
Error.throwWithStackTrace(
TestFailure("Expected element: `$selectors` ; root: `$root`"),
stackTrace);
}
return ok;
});
}