public interface TaskRepeater extends TimeoutRelated<TaskRepeater>
Executes a single task multiple times. The task itself is specified with the Task interface.
The methods of this interface are paying respect to the ibello timeout settings. With the TimeoutRelated.withTimeout(Enum)
or TimeoutRelated.withTimeout(String) methods we can specify a concrete timeout value. If we don't do that then the default timeout will be used.
With the untilSucceeds() and untilFails() methods we can start the repeat process - with a specific exit condition.
| Modifier and Type | Method and Description |
|---|---|
void |
untilFails()
Repeats the task until it fails or the time ends.
|
void |
untilSucceeds()
Repeats the task until it succeeds or the time ends.
|
withTimeout, withTimeoutvoid untilSucceeds()
Repeats the task until it succeeds or the time ends. If the task fails during the timeout, it will be executed again. If the timeout ends and the task did not succeeded at least once, this method will throw an exception (and will fail).
The minimum number of the retries is 2. Therefore the task is executed at least 3 times before this method ends with failure.
Between the executions the method waits a few milliseconds - the concrete size of the waiting time depends on the timeout of the
TaskRepeater instance. Bigger timeout means bigger waiting time.
The task fails if it throws an exception (or any Throwable). Ibello soft expectations (eg. ExpectationBuilder.assume(hu.ibello.elements.WebElement))
are not throwing exceptions. Therefore if we use a soft expectation in the task body, and it fails, the task will not fail because of it.
void untilFails()
Repeats the task until it fails or the time ends. If the task succeeds during the timeout, it will be executed again. If the timeout ends and the task did not failed at least once, this method will throw an exception (and will fail).
The minimum number of the retries is 2. Therefore the task is executed at least 3 times before this method ends with failure.
Between the executions the method waits a few milliseconds - the concrete size of the waiting time depends on the timeout of the
TaskRepeater instance. Bigger timeout means bigger waiting time.
The task fails if it throws an exception (or any Throwable). Ibello soft expectations (eg. ExpectationBuilder.assume(hu.ibello.elements.WebElement))
are not throwing exceptions. Therefore if we use a soft expectation in the task body, and it fails, the task will not fail because of it.
Created by Kornél Simon, 2022