Async topic
Several utilities are provided for dealing with asynchronous code. The functions are linked below.
These can be useful to wait for an element to appear or disappear in response to an event, user action, timeout, or Future. (See the guide to testing disappearance.)
Read the JS async methods docs for more in-depth discussion and examples
Functions
-
findAllByAltText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByAltText QueriesList< E> > -
Returns a list of ImageElements, InputElements and/or AreaElements with the given
textas the value of thealtattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
findAllByDisplayValue<
E extends Element> (Node container, dynamic value, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByDisplayValue QueriesList< E> > -
Returns a list of InputElement, TextAreaElement or SelectElement that has the matching
valuedisplayed, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findAllByLabelText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, String? selector, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByLabelText QueriesList< E> > -
Returns a list of elements that are associated with a LabelElement with the given
text, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findAllByPlaceholderText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByPlaceholderText QueriesList< E> > -
Returns a list of elements with the given
textas the value of theplaceholderattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
findAllByRole<
E extends Element> (Node container, dynamic role, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, dynamic name, bool? selected, bool? checked, bool? pressed, bool? expanded, bool queryFallbacks = false, int? level, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByRole QueriesList< E> > -
Returns a list of elements with the given
rolevalue, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findAllByTestId<
E extends Element> (Node container, dynamic testId, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByTestId QueriesList< E> > -
Returns a list of elements with the given
testIdvalue for thedata-test-idattribute, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findAllByText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, String? selector, dynamic ignore = 'script', Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByText QueriesList< E> > -
Returns a list of elements with the given
textcontent, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findAllByTitle<
E extends Element> (Node container, dynamic title, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByTitle QueriesList< E> > -
Returns a list of elements with the given
titleas the value of thetitleattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
findByAltText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByAltText QueriesE> -
Returns a future with a single ImageElement, InputElement or AreaElement value with the given
textas the value of thealtattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
findByDisplayValue<
E extends Element> (Node container, dynamic value, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByDisplayValue QueriesE> -
Returns a future with a single InputElement, TextAreaElement or SelectElement that has the matching
valuedisplayed, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findByLabelText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, String? selector, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByLabelText QueriesE> -
Returns a future with a single element that is associated with a LabelElement with the given
text, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findByPlaceholderText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByPlaceholderText QueriesE> -
Returns a future with a single element value with the given
textas the value of theplaceholderattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
findByRole<
E extends Element> (Node container, dynamic role, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, dynamic name, bool? selected, bool? checked, bool? pressed, bool? expanded, bool queryFallbacks = false, int? level, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByRole QueriesE> -
Returns a future with a single element value with the given
rolevalue, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findByTestId<
E extends Element> (Node container, dynamic testId, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByTestId QueriesE> -
Returns a future with a single element value with the given
testIdvalue for thedata-test-idattribute, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findByText<
E extends Element> (Node container, dynamic text, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, String? selector, dynamic ignore = 'script', Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByText QueriesE> -
Returns a future with a single element value with the given
textcontent, defaulting to anexactmatch after waiting 1000ms (or the providedtimeoutduration). -
findByTitle<
E extends Element> (Node container, dynamic title, {bool exact = true, NormalizerFn normalizer([NormalizerOptions?])?, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Async ByTitle QueriesE> -
Returns a future with a single element value with the given
titleas the value of thetitleattribute, defaulting to anexactmatch after waiting1000ms(or the specifiedtimeoutduration). -
waitFor<
T> (FutureOr< AsyncT> expectation(), {Node? container, Duration? timeout, Duration interval = defaultAsyncCallbackCheckInterval, QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future<T> -
Calls the provided
expectationon a givenintervaland/or when thecontainerDOM changes, completing only if it does notthrow, or bythrowing if thetimeoutexpires before theexpectationsucceeds. -
waitForElementsToBeRemoved(
List< AsyncNode> callback(), {Node? container, Duration? timeout, Duration interval = const Duration(milliseconds: 50), QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future<void> -
Waits for the removal of all the elements returned from the
callbackto be removed from the DOM. -
waitForElementToBeRemoved(
Node callback(), {Node? container, Duration? timeout, Duration interval = const Duration(milliseconds: 50), QueryTimeoutFn? onTimeout, MutationObserverOptions mutationObserverOptions = defaultMutationObserverOptions}) → Future< Asyncvoid> -
Waits for the removal of the single element returned from the
callbackto be removed from the DOM.