Package org.fluentlenium.core.wait
Class FluentWait
- java.lang.Object
-
- org.fluentlenium.core.wait.FluentWait
-
- All Implemented Interfaces:
FluentWaitConditions<FluentWait>,FluentWaitConfiguration<FluentWait>,FluentWaitFunctional<FluentControl>,org.openqa.selenium.support.ui.Wait<FluentControl>
public class FluentWait extends java.lang.Object implements FluentWaitFunctional<FluentControl>, FluentWaitConditions<FluentWait>, FluentWaitConfiguration<FluentWait>
A wait object wrapping default seleniumFluentWaitobject into a more complete API, allowing to wait for any condition to be verified.
-
-
Constructor Summary
Constructors Constructor Description FluentWait(FluentControl control)Creates a new fluent wait.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FluentWaitatMost(java.time.Duration duration)Configure timeout for this wait object.FluentWaitexplicitlyFor(long amount, java.util.concurrent.TimeUnit timeUnit)Waits unconditionally for an explicit amount of time.org.openqa.selenium.support.ui.FluentWaitgetWait()Get the underlying selenium wait objectbooleanhasMessageDefined()Check if a message is defined.FluentWaitignoreAll(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> types)Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.FluentWaitignoring(java.lang.Class<? extends java.lang.RuntimeException> exceptionType)Add given exception to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.FluentWaitignoring(java.lang.Class<? extends java.lang.RuntimeException> firstType, java.lang.Class<? extends java.lang.RuntimeException> secondType)Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.FluentWaitpollingEvery(java.time.Duration duration)Configure polling time for this wait object.<T> Tuntil(java.util.function.Function<? super FluentControl,T> function)Wait until the function returns a non-null and non-false object.voiduntil(java.util.function.Supplier<java.lang.Boolean> booleanSupplier)Wait until the supplier returns true.FluentListConditionsuntil(java.util.List<? extends FluentWebElement> elements)Get a conditions object used to wait for a condition on given elements.FluentConditionsuntil(FluentWebElement element)Get a conditions object used to wait for condition on given element.FluentListConditionsuntilEach(java.util.List<? extends FluentWebElement> elements)Get a conditions object used to wait for a condition on given elements.FluentListConditionsuntilEachElements(java.util.function.Supplier<? extends java.util.List<? extends FluentWebElement>> elements)Get a conditions object used to wait for a condition on given elements.FluentConditionsuntilElement(java.util.function.Supplier<? extends FluentWebElement> element)Get a conditions object used to wait for a condition on given element.FluentListConditionsuntilElements(java.util.function.Supplier<? extends java.util.List<? extends FluentWebElement>> elements)Get a conditions object used to wait for a condition on given elements.FluentWaitPageConditionsuntilPage()Get a condition object used to wait for a page condition.FluentWaitPageConditionsuntilPage(FluentPage page)Get a condition object used to wait for a page condition.voiduntilPredicate(java.util.function.Predicate<FluentControl> predicate)Wait until the predicate returns true.FluentWaitWindowConditionsuntilWindow(java.lang.String windowName)Get a condition object used to wait for a window condition.FluentWaitwithMessage(java.util.function.Supplier<java.lang.String> message)Configures a custom message supplier to be used if the condition fails during the timeout duration.FluentWaitwithNoDefaultsException()Removes default exceptions from exceptions ignore list.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fluentlenium.core.wait.FluentWaitConditions
explicitlyFor
-
Methods inherited from interface org.fluentlenium.core.wait.FluentWaitConfiguration
atMost, atMost, pollingEvery, pollingEvery, withMessage
-
-
-
-
Constructor Detail
-
FluentWait
public FluentWait(FluentControl control)
Creates a new fluent wait.- Parameters:
control- control interface
-
-
Method Detail
-
getWait
public org.openqa.selenium.support.ui.FluentWait getWait()
Description copied from interface:FluentWaitConfigurationGet the underlying selenium wait object- Specified by:
getWaitin interfaceFluentWaitConfiguration<FluentWait>- Returns:
- selenium wait
-
atMost
public FluentWait atMost(java.time.Duration duration)
Description copied from interface:FluentWaitConfigurationConfigure timeout for this wait object.- Specified by:
atMostin interfaceFluentWaitConfiguration<FluentWait>- Parameters:
duration- duration- Returns:
thisobject to chain method calls
-
pollingEvery
public FluentWait pollingEvery(java.time.Duration duration)
Description copied from interface:FluentWaitConfigurationConfigure polling time for this wait object.- Specified by:
pollingEveryin interfaceFluentWaitConfiguration<FluentWait>- Parameters:
duration- duration between each condition invocation- Returns:
thisobject to chain method calls
-
ignoreAll
public FluentWait ignoreAll(java.util.Collection<java.lang.Class<? extends java.lang.Throwable>> types)
Description copied from interface:FluentWaitConfigurationAdd given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoreAllin interfaceFluentWaitConfiguration<FluentWait>- Parameters:
types- collection of exception type to ignore- Returns:
thisobject to chain method calls
-
ignoring
public FluentWait ignoring(java.lang.Class<? extends java.lang.RuntimeException> exceptionType)
Description copied from interface:FluentWaitConfigurationAdd given exception to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoringin interfaceFluentWaitConfiguration<FluentWait>- Parameters:
exceptionType- exception type to ignore- Returns:
thisobject to chain method calls
-
ignoring
public FluentWait ignoring(java.lang.Class<? extends java.lang.RuntimeException> firstType, java.lang.Class<? extends java.lang.RuntimeException> secondType)
Description copied from interface:FluentWaitConfigurationAdd given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoringin interfaceFluentWaitConfiguration<FluentWait>- Parameters:
firstType- exception type to ignoresecondType- exception type to ignore- Returns:
thisobject to chain method calls
-
withMessage
public FluentWait withMessage(java.util.function.Supplier<java.lang.String> message)
Description copied from interface:FluentWaitConfigurationConfigures a custom message supplier to be used if the condition fails during the timeout duration.- Specified by:
withMessagein interfaceFluentWaitConfiguration<FluentWait>- Parameters:
message- failing message- Returns:
thisobject to chain method calls
-
withNoDefaultsException
public FluentWait withNoDefaultsException()
Description copied from interface:FluentWaitConfigurationRemoves default exceptions from exceptions ignore list.- Specified by:
withNoDefaultsExceptionin interfaceFluentWaitConfiguration<FluentWait>- Returns:
thisobject to chain method calls
-
hasMessageDefined
public boolean hasMessageDefined()
Check if a message is defined.- Specified by:
hasMessageDefinedin interfaceFluentWaitConfiguration<FluentWait>- Returns:
- true if this fluent wait use a custom message, false otherwise
-
untilPredicate
public void untilPredicate(java.util.function.Predicate<FluentControl> predicate)
Description copied from interface:FluentWaitFunctionalWait until the predicate returns true.- Specified by:
untilPredicatein interfaceFluentWaitFunctional<FluentControl>- Parameters:
predicate- predicate condition to wait for
-
until
public void until(java.util.function.Supplier<java.lang.Boolean> booleanSupplier)
Description copied from interface:FluentWaitFunctionalWait until the supplier returns true.- Specified by:
untilin interfaceFluentWaitFunctional<FluentControl>- Parameters:
booleanSupplier- supplier condition to wait for.
-
until
public <T> T until(java.util.function.Function<? super FluentControl,T> function)
Description copied from interface:FluentWaitFunctionalWait until the function returns a non-null and non-false object.- Specified by:
untilin interfaceFluentWaitFunctional<FluentControl>- Specified by:
untilin interfaceorg.openqa.selenium.support.ui.Wait<FluentControl>- Type Parameters:
T- type of returned object- Parameters:
function- function returning a non-null and non-false object when condition is verified.- Returns:
- object returned by function
-
until
public FluentConditions until(FluentWebElement element)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for condition on given element.- Specified by:
untilin interfaceFluentWaitConditions<FluentWait>- Parameters:
element- element to wait for- Returns:
- conditions object
-
until
public FluentListConditions until(java.util.List<? extends FluentWebElement> elements)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for a condition on given elements.At least one element must verify the condition to be verified.
- Specified by:
untilin interfaceFluentWaitConditions<FluentWait>- Parameters:
elements- elements to wait for- Returns:
- conditions object
-
untilEach
public FluentListConditions untilEach(java.util.List<? extends FluentWebElement> elements)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for a condition on given elements.Each element must verify the condition to be verified.
- Specified by:
untilEachin interfaceFluentWaitConditions<FluentWait>- Parameters:
elements- elements to wait for- Returns:
- conditions object
-
untilElement
public FluentConditions untilElement(java.util.function.Supplier<? extends FluentWebElement> element)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for a condition on given element.- Specified by:
untilElementin interfaceFluentWaitConditions<FluentWait>- Parameters:
element- element to wait for- Returns:
- conditions object
-
untilElements
public FluentListConditions untilElements(java.util.function.Supplier<? extends java.util.List<? extends FluentWebElement>> elements)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for a condition on given elements.At least one element must verify the condition to be verified.
- Specified by:
untilElementsin interfaceFluentWaitConditions<FluentWait>- Parameters:
elements- elements to wait for- Returns:
- conditions object
-
untilEachElements
public FluentListConditions untilEachElements(java.util.function.Supplier<? extends java.util.List<? extends FluentWebElement>> elements)
Description copied from interface:FluentWaitConditionsGet a conditions object used to wait for a condition on given elements.Each element must verify the condition to be verified.
- Specified by:
untilEachElementsin interfaceFluentWaitConditions<FluentWait>- Parameters:
elements- elements to wait for- Returns:
- conditions object
-
untilWindow
public FluentWaitWindowConditions untilWindow(java.lang.String windowName)
Description copied from interface:FluentWaitConditionsGet a condition object used to wait for a window condition.- Specified by:
untilWindowin interfaceFluentWaitConditions<FluentWait>- Parameters:
windowName- name of the window to wait for- Returns:
- window conditions object
-
untilPage
public FluentWaitPageConditions untilPage()
Description copied from interface:FluentWaitConditionsGet a condition object used to wait for a page condition.- Specified by:
untilPagein interfaceFluentWaitConditions<FluentWait>- Returns:
- page conditions object
-
untilPage
public FluentWaitPageConditions untilPage(FluentPage page)
Description copied from interface:FluentWaitConditionsGet a condition object used to wait for a page condition.- Specified by:
untilPagein interfaceFluentWaitConditions<FluentWait>- Parameters:
page- page to wait for- Returns:
- page conditions object
-
explicitlyFor
public FluentWait explicitlyFor(long amount, java.util.concurrent.TimeUnit timeUnit)
Description copied from interface:FluentWaitConditionsWaits unconditionally for an explicit amount of time.The method should be used only as a last resort.
In most cases you should wait for some condition, e.g. visibility of particular element on the page.
- Specified by:
explicitlyForin interfaceFluentWaitConditions<FluentWait>- Parameters:
amount- amount of timetimeUnit- unit of time- Returns:
thisobject to chain method calls
-
-