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.FluentWaitgetWait()Get the underlying selenium wait objectbooleanCheck 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.until(FluentWebElement element) Get a conditions object used to wait for condition on given element.<T> Tuntil(Function<? super FluentControl, T> function) Wait until the function returns a non-null and non-false object.voidWait until the supplier returns true.until(List<? extends FluentWebElement> elements) Get a conditions object used to wait for a condition on given elements.untilAsserted(Runnable block) waits until aRunnableblock 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.voiduntilPredicate(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, waitMethods inherited from interface io.fluentlenium.core.wait.FluentWaitConditions
explicitlyForMethods 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:FluentWaitConfigurationGet the underlying selenium wait object- Specified by:
getWaitin interfaceFluentWaitConfiguration<FluentWait>- Returns:
- selenium wait
-
atMost
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
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
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
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(Class<? extends RuntimeException> firstType, Class<? extends 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
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
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
Description copied from interface:FluentWaitFunctionalWait until the predicate returns true.- Specified by:
untilPredicatein interfaceFluentWaitFunctional<FluentControl>- Parameters:
predicate- predicate condition to wait for
-
until
Description copied from interface:FluentWaitFunctionalWait until the supplier returns true.- Specified by:
untilin interfaceFluentWaitFunctional<FluentControl>- Parameters:
booleanSupplier- supplier condition to wait for.
-
until
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
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
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
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
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(Supplier<? extends 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(Supplier<? extends 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
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
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
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
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
-
untilAsserted
Description copied from interface:FluentWaitConditionswaits until aRunnableblock 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:
untilAssertedin interfaceFluentWaitConditions<FluentWait>- Parameters:
block- the code block that is responsible for executing the assertion and throwing AssertionError on failure.- Returns:
thisobject to chain method calls
-