Operations

public class Operations

Internal implementation of various browser operations

Methods

doWithRetries

public static void doWithRetries(Runnable action, int numberOfRetries, int sleepInMillisec)

Retry an action/assertion up to a number of times, with delay after each time. For example:

doWithRetries(() -> assertThat(div.withClass("foo"), isDisplayedIn(browser)), 5, 10);
Parameters:
  • action – the action to try. It’s a runnable - no input parapeters and does not return anything.
  • numberOfRetries
    • maximum number of retries
  • sleepInMillisec
    • delay between consecutive retries

doWithRetries

public static <T> T doWithRetries(Callable<T> action, int numberOfRetries, int sleepInMillisec)

Retry an action up to a number of times, with delay after each time. For example:

WebElement el = doWithRetries(() -> browser.find(div.withClass("foo"), 5, 10);
Parameters:
  • action – the action to try. It has no input parameters, but returns a value
  • numberOfRetries
    • maximum number of retries
  • sleepInMillisec
    • delay between consecutive retries
  • <T> – any type that the function returns
Throws:
  • Exception – the exception thrown by the last try in case it exceeded the number of retries.
Returns:

returns the result of the callable