Package io.fluentlenium.core.wait
Class FluentWait
java.lang.Object
io.fluentlenium.core.wait.FluentWait
- All Implemented Interfaces:
FluentWaitConditions<FluentWait>
,FluentWaitConfiguration<FluentWait>
,FluentWaitFunctional<FluentControl>
,org.openqa.selenium.support.ui.Wait<FluentControl>
public class FluentWait
extends Object
implements FluentWaitFunctional<FluentControl>, FluentWaitConditions<FluentWait>, FluentWaitConfiguration<FluentWait>
A wait object wrapping default selenium
FluentWait
object into a more
complete API, allowing to wait for any condition to be verified.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConfigure timeout for this wait object.explicitlyFor
(long amount, TimeUnit timeUnit) Waits unconditionally for an explicit amount of time.org.openqa.selenium.support.ui.FluentWait
getWait()
Get the underlying selenium wait objectboolean
Check if a message is defined.ignoreAll
(Collection<Class<? extends Throwable>> types) Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.ignoring
(Class<? extends RuntimeException> exceptionType) Add given exception to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.ignoring
(Class<? extends RuntimeException> firstType, Class<? extends RuntimeException> secondType) Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.pollingEvery
(Duration duration) Configure polling time for this wait object.<T> T
until
(Function<? super FluentControl, T> function) Wait until the function returns a non-null and non-false object.void
Wait until the supplier returns true.until
(List<? extends FluentWebElement> elements) Get a conditions object used to wait for a condition on given elements.until
(FluentWebElement element) Get a conditions object used to wait for condition on given element.untilAsserted
(Runnable block) waits until aRunnable
block execution ends without throwing an exception.untilEach
(List<? extends FluentWebElement> elements) Get a conditions object used to wait for a condition on given elements.untilEachElements
(Supplier<? extends List<? extends FluentWebElement>> elements) Get a conditions object used to wait for a condition on given elements.untilElement
(Supplier<? extends FluentWebElement> element) Get a conditions object used to wait for a condition on given element.untilElements
(Supplier<? extends List<? extends FluentWebElement>> elements) Get a conditions object used to wait for a condition on given elements.Get a condition object used to wait for a page condition.untilPage
(FluentPage page) Get a condition object used to wait for a page condition.void
untilPredicate
(Predicate<FluentControl> predicate) Wait until the predicate returns true.untilWindow
(String windowName) Get a condition object used to wait for a window condition.withMessage
(Supplier<String> message) Configures a custom message supplier to be used if the condition fails during the timeout duration.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 io.fluentlenium.core.wait.FluentWaitConditions
explicitlyFor
Methods inherited from interface io.fluentlenium.core.wait.FluentWaitConfiguration
atMost, atMost, pollingEvery, pollingEvery, withMessage
-
Constructor Details
-
FluentWait
Creates a new fluent wait.- Parameters:
control
- control interface
-
-
Method Details
-
getWait
public org.openqa.selenium.support.ui.FluentWait getWait()Description copied from interface:FluentWaitConfiguration
Get the underlying selenium wait object- Specified by:
getWait
in interfaceFluentWaitConfiguration<FluentWait>
- Returns:
- selenium wait
-
atMost
Description copied from interface:FluentWaitConfiguration
Configure timeout for this wait object.- Specified by:
atMost
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
duration
- duration- Returns:
this
object to chain method calls
-
pollingEvery
Description copied from interface:FluentWaitConfiguration
Configure polling time for this wait object.- Specified by:
pollingEvery
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
duration
- duration between each condition invocation- Returns:
this
object to chain method calls
-
ignoreAll
Description copied from interface:FluentWaitConfiguration
Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoreAll
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
types
- collection of exception type to ignore- Returns:
this
object to chain method calls
-
ignoring
Description copied from interface:FluentWaitConfiguration
Add given exception to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoring
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
exceptionType
- exception type to ignore- Returns:
this
object to chain method calls
-
ignoring
public FluentWait ignoring(Class<? extends RuntimeException> firstType, Class<? extends RuntimeException> secondType) Description copied from interface:FluentWaitConfiguration
Add given exceptions to ignore list to avoid breaking the wait when they occurs in the underlying condition evaluation.- Specified by:
ignoring
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
firstType
- exception type to ignoresecondType
- exception type to ignore- Returns:
this
object to chain method calls
-
withMessage
Description copied from interface:FluentWaitConfiguration
Configures a custom message supplier to be used if the condition fails during the timeout duration.- Specified by:
withMessage
in interfaceFluentWaitConfiguration<FluentWait>
- Parameters:
message
- failing message- Returns:
this
object to chain method calls
-
withNoDefaultsException
Description copied from interface:FluentWaitConfiguration
Removes default exceptions from exceptions ignore list.- Specified by:
withNoDefaultsException
in interfaceFluentWaitConfiguration<FluentWait>
- Returns:
this
object to chain method calls
-
hasMessageDefined
public boolean hasMessageDefined()Check if a message is defined.- Specified by:
hasMessageDefined
in interfaceFluentWaitConfiguration<FluentWait>
- Returns:
- true if this fluent wait use a custom message, false otherwise
-
untilPredicate
Description copied from interface:FluentWaitFunctional
Wait until the predicate returns true.- Specified by:
untilPredicate
in interfaceFluentWaitFunctional<FluentControl>
- Parameters:
predicate
- predicate condition to wait for
-
until
Description copied from interface:FluentWaitFunctional
Wait until the supplier returns true.- Specified by:
until
in interfaceFluentWaitFunctional<FluentControl>
- Parameters:
booleanSupplier
- supplier condition to wait for.
-
until
Description copied from interface:FluentWaitFunctional
Wait until the function returns a non-null and non-false object.- Specified by:
until
in interfaceFluentWaitFunctional<FluentControl>
- Specified by:
until
in 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
Description copied from interface:FluentWaitConditions
Get a conditions object used to wait for condition on given element.- Specified by:
until
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
element
- element to wait for- Returns:
- conditions object
-
until
Description copied from interface:FluentWaitConditions
Get 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:
until
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
elements
- elements to wait for- Returns:
- conditions object
-
untilEach
Description copied from interface:FluentWaitConditions
Get a conditions object used to wait for a condition on given elements.Each element must verify the condition to be verified.
- Specified by:
untilEach
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
elements
- elements to wait for- Returns:
- conditions object
-
untilElement
Description copied from interface:FluentWaitConditions
Get a conditions object used to wait for a condition on given element.- Specified by:
untilElement
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
element
- element to wait for- Returns:
- conditions object
-
untilElements
public FluentListConditions untilElements(Supplier<? extends List<? extends FluentWebElement>> elements) Description copied from interface:FluentWaitConditions
Get 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:
untilElements
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
elements
- elements to wait for- Returns:
- conditions object
-
untilEachElements
public FluentListConditions untilEachElements(Supplier<? extends List<? extends FluentWebElement>> elements) Description copied from interface:FluentWaitConditions
Get a conditions object used to wait for a condition on given elements.Each element must verify the condition to be verified.
- Specified by:
untilEachElements
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
elements
- elements to wait for- Returns:
- conditions object
-
untilWindow
Description copied from interface:FluentWaitConditions
Get a condition object used to wait for a window condition.- Specified by:
untilWindow
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
windowName
- name of the window to wait for- Returns:
- window conditions object
-
untilPage
Description copied from interface:FluentWaitConditions
Get a condition object used to wait for a page condition.- Specified by:
untilPage
in interfaceFluentWaitConditions<FluentWait>
- Returns:
- page conditions object
-
untilPage
Description copied from interface:FluentWaitConditions
Get a condition object used to wait for a page condition.- Specified by:
untilPage
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
page
- page to wait for- Returns:
- page conditions object
-
explicitlyFor
Description copied from interface:FluentWaitConditions
Waits 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:
explicitlyFor
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
amount
- amount of timetimeUnit
- unit of time- Returns:
this
object to chain method calls
-
untilAsserted
Description copied from interface:FluentWaitConditions
waits until aRunnable
block execution ends without throwing an exception. The method is intended to be used with Java 8 Lambda expressions. This allows to use AssertJ/JUnit/TestNG assertions to periodically check for conditions.await().untilAsserted(() -> assertThat(window().title()).isEqualTo("Fluentlenium"));
- Specified by:
untilAsserted
in interfaceFluentWaitConditions<FluentWait>
- Parameters:
block
- the code block that is responsible for executing the assertion and throwing AssertionError on failure.- Returns:
this
object to chain method calls
-