The context for automation.
A function that should be retried on exception.
Optional
options: RetryOptionsOptions for retry.
The return value of the function.
Runs a function and retries it on exception up to maxTries
times, after
which it will reject with the last thrown exception, and otherwise return the
original result.
Most often, the retry function should contain not only the action that can fail, but also its success condition (eg. a particular selector appears, or the response does not contain errors) which checks if the action should be repeated. To cause a retry, simply throw anywhere from the retry function.
This makes certain operations more resilient, like clicking on unresponsive user interfaces, making navigation or API requests to unstable systems, or retrying entire transactions.
await retry(ctx, async () => {
await click(ctx, '.button');
await waitForSelector(ctx, '.success.notification', {timeout: 3000});
});
const value = await retry(ctx, async () => {
await click(ctx, '.button');
return getValue(ctx, '.result');
}, {
maxTries: 3,
retryDelay: 500,
});
Generated using TypeDoc
Runs a function and retries it on exception.