Package org.kquiet.browser.action
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
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:
- the condition function returns neither null nor false
- the condition function throws an unignored exception
- the timeout expires
- 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 Summary
ConstructorsConstructorDescriptionCreate an action to wait with default phased timeout and polling interval until conditions are met or timed out.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.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.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.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.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Perform multiple-phased browser action.toString()
Methods inherited from class org.kquiet.browser.action.MultiPhaseAction
getActionState, getComposer, getCostTime, getErrors, hasNextPhase, isDone, isFail, noNextPhase, perform, setActionState, setComposer, switchToTopForFirefox
-
Constructor Details
-
WaitUntil
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 phasestotalTimeout
- 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 phasestotalTimeout
- the maximum amount of time to wait totallyphaseTimeout
- the maximum amount of time to wait for each execution phasepollInterval
- 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 phasestotalTimeout
- the maximum amount of time to wait totallytimeoutCallback
- 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 phasestotalTimeout
- the maximum amount of time to wait totallyignoreExceptions
- 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 phasestotalTimeout
- the maximum amount of time to wait totallyignoreExceptions
- 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 phasestotalTimeout
- the maximum amount of time to wait totallyphaseTimeout
- the maximum amount of time to wait for each execution phasepollInterval
- 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, thenStaleElementReferenceException
andNoSuchElementException
are ignored; otherwise the given types of exceptions are used.timeoutCallback
- the callback function to be called when total timeout expires
-
-
Method Details
-
performMultiPhase
protected void performMultiPhase()Description copied from class:MultiPhaseAction
Perform multiple-phased browser action.MultiPhaseAction.noNextPhase()
needs to be invoked to signal that there is no more phase to execute.- Specified by:
performMultiPhase
in classMultiPhaseAction
-
toString
- Overrides:
toString
in classMultiPhaseAction
-