๐ฌ .while(condition, action, options)
This is a proposal for functionality that may be implemented in the future.
TODO: Description here.
Usage
element(matcher).while(condition, action, options)
Parameters
condition
(Function
):element
(Element
): Reference to current element to apply assertions against.[ReturnType]
(Promise
): Returning a Promise that resolves will retry until it rejects or exceedsoptions.maxDuration
.
action
(Function
):element
(Element
): Reference to current element to apply action against.[ReturnType]
(Promise
): A Promise that attempts to makecondition
reject.
options
(Object?
):options.interval
(Number?
): Duration in milliseconds to wait between polling. Defaults to 200.options.maxDuration
(Number?
): Max duration in milliseconds to poll before throwing. Defaults to 10000.
Returns
Element
: A new element to avoid mutation and allow function chaining.
Support
Platform | Supported |
---|---|
iOS | Yes |
Android | Yes |
Web | Yes |
Examples
Set date picker values (iOS):
const { element, by } = require("appdriver");
(async () => {
const [ $month, $day, $year ] = await element(by.type("XCUIElementTypePickerWheel"));
const day = "11";
const month = "May";
const year = "2050";
await $month.while(
($e) => expect($e).not.toHaveValue(month),
($e) => $e.setValue(month)
);
await $day.while(
($e) => expect($e).not.toHaveValue(day),
($e) => $e.setValue(day)
);
await $year.while(
($e) => expect($e).not.toHaveValue(year),
($e) => $e.setValue(year)
);
})();