Class Operations


  • public class Operations
    extends Object
    Internal implementation of various browser operations
    • Constructor Detail

      • Operations

        public Operations()
    • Method Detail

      • 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)
                                   throws Exception
        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);
         
         
        Type Parameters:
        T - any type that the function returns
        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
        Returns:
        returns the result of the callable
        Throws:
        Exception - the exception thrown by the last try in case it exceeded the number of retries.
      • doWithRetriesForException

        public static <T,​V extends Exception> T doWithRetriesForException​(Callable<T> action,
                                                                                Class<V> exceptionClass,
                                                                                int numberOfRetries,
                                                                                int sleepInMillisec)
                                                                         throws Exception
        Throws:
        Exception