Class WaitUntil<V>

java.lang.Object
org.kquiet.browser.action.MultiPhaseAction
org.kquiet.browser.action.WaitUntil<V>
Type Parameters:
V - the expected return type of condition function
All Implemented Interfaces:
Composable, MultiPhased

public class WaitUntil<V> extends MultiPhaseAction
WaitUntil is a subclass of MultiPhaseAction which waits the evaluation result of condition function by phases to avoid blocking the execution of other browser actions.

WaitUntil waits until one of the following occurs:

  1. the condition function returns neither null nor false
  2. the condition function throws an unignored exception
  3. the timeout expires
  4. the execution thread of this WaitUntil is interrupted

When timeout expires, it will throw an ActionException if no timeout callback function is supplied; if a timeout callback function is supplied, it will execute the callback function instead of throwing ActionException.

Author:
Kimberly
  • Constructor Details

    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout)
      Create an action to wait with default phased timeout and polling interval until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout, int phaseTimeout, int pollInterval)
      Create an action to wait until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
      phaseTimeout - the maximum amount of time to wait for each execution phase
      pollInterval - how often the condition function should be evaluated(the cost of actually evaluating the condition function is not factored in)
    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout, Consumer<ActionComposer> timeoutCallback)
      Create an action to wait with default phased timeout and polling interval until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
      timeoutCallback - the callback function to be called when total timeout expires
    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout, Set<Class<? extends Throwable>> ignoreExceptions)
      Create an action to wait with default phased timeout and polling interval until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
      ignoreExceptions - the types of exceptions to ignore when evaluating condition function;
    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout, Set<Class<? extends Throwable>> ignoreExceptions, Consumer<ActionComposer> timeoutCallback)
      Create an action to wait with default phased timeout and polling interval until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
      ignoreExceptions - the types of exceptions to ignore when evaluating condition function;
      timeoutCallback - the callback function to be called when total timeout expires
    • WaitUntil

      public WaitUntil(Function<org.openqa.selenium.WebDriver,V> conditionFunc, int totalTimeout, int phaseTimeout, int pollInterval, Set<Class<? extends Throwable>> ignoreExceptions, Consumer<ActionComposer> timeoutCallback)
      Create an action to wait until conditions are met or timed out.
      Parameters:
      conditionFunc - the condition function for evaluation by phases
      totalTimeout - the maximum amount of time to wait totally
      phaseTimeout - the maximum amount of time to wait for each execution phase
      pollInterval - how often the condition function should be evaluated(the cost of actually evaluating the condition function is not factored in)
      ignoreExceptions - the types of exceptions to ignore when evaluating condition function. If this parameter value is null or empty, then StaleElementReferenceException and NoSuchElementException are ignored; otherwise the given types of exceptions are used.
      timeoutCallback - the callback function to be called when total timeout expires
  • Method Details