public class WaitHelper extends Object
Many JavaScript frameworks operate by manipulating the page DOM either by adding/removing or by showing/hiding elements as a consequence of a user action: this implies your test code needs to synchronize with those asynchronous events in order to proceed.
The utility methods presented in here provide the basic facility to create this synchronization points.
More advanced synchronization than presented here is achievable by directly
using the org.openqa.selenium.support.ui.Wait or
org.openqa.selenium.support.ui.FluentWait APIs and the code
provided hereby can be used as a reference for such advanced usage.
| Modifier | Constructor and Description |
|---|---|
protected |
WaitHelper(org.openqa.selenium.SearchContext context,
long duration,
TimeUnit timeUnit) |
| Modifier and Type | Method and Description |
|---|---|
org.openqa.selenium.WebElement |
until(org.openqa.selenium.By by,
org.hamcrest.Matcher<org.openqa.selenium.WebElement> matcher)
Holds the execution until an element matching the search condition is
found and the generic matcher is verified or not found or
the maximum wait expires.
|
org.openqa.selenium.WebElement |
untilAdded(org.openqa.selenium.By by)
Holds the execution until an element matching the search condition is
found or the maximum wait expires.
|
List<org.openqa.selenium.WebElement> |
untilCount(org.openqa.selenium.By by,
int count)
Holds the execution until at the elements count matching the search
condition matches the provided count or the maximum wait expires.
|
List<org.openqa.selenium.WebElement> |
untilCount(org.openqa.selenium.By by,
org.hamcrest.Matcher<Integer> matcher)
Holds the execution until at the elements count matching the search
condition matches with the generic matcher condition or the
maximum wait expires.
|
org.openqa.selenium.WebElement |
untilDisabled(org.openqa.selenium.By by)
Holds the execution until an element matching the search condition is
found and disabled or the maximum wait expires.
|
org.openqa.selenium.WebElement |
untilEnabled(org.openqa.selenium.By by)
Holds the execution until an element matching the search condition is
found and enabled or the maximum wait expires.
|
org.openqa.selenium.WebElement |
untilHidden(org.openqa.selenium.By by)
Holds the execution until an element matching the search condition is
found and non visible or the maximum wait expires.
|
org.openqa.selenium.WebElement |
untilRemoved(org.openqa.selenium.By by)
Holds the execution until no element matching the search condition
is found or the maximum wait expires.
|
org.openqa.selenium.WebElement |
untilShown(org.openqa.selenium.By by)
Holds the execution until an element matching the search condition is
found and visible or the maximum wait expires.
|
static WaitHelper |
waitOn(org.openqa.selenium.SearchContext context,
long millis) |
static WaitHelper |
waitOn(org.openqa.selenium.SearchContext context,
long duration,
TimeUnit timeUnit) |
protected WaitHelper(org.openqa.selenium.SearchContext context,
long duration,
TimeUnit timeUnit)
context - the WebDriver or WebElement used as
search rootduration - the maximum wait durationtimeUnit - the maximum wait time unitpublic static WaitHelper waitOn(org.openqa.selenium.SearchContext context, long millis)
context - the WebDriver or WebElement used as
search rootmillis - the maximum wait in millisecondsWaitHelper instance operating on the above
parameterspublic static WaitHelper waitOn(org.openqa.selenium.SearchContext context, long duration, TimeUnit timeUnit)
context - the WebDriver or WebElement used as
search rootduration - the maximum wait durationtimeUnit - the maximum wait time unitWaitHelper instance operating on the above
parameterspublic org.openqa.selenium.WebElement untilAdded(org.openqa.selenium.By by)
by - search conditionpublic org.openqa.selenium.WebElement untilRemoved(org.openqa.selenium.By by)
null and,
even when it is not, it represents a stale node.by - search conditionnull if the
element was never foundpublic org.openqa.selenium.WebElement untilShown(org.openqa.selenium.By by)
by - search conditionpublic org.openqa.selenium.WebElement untilHidden(org.openqa.selenium.By by)
by - search conditionpublic org.openqa.selenium.WebElement untilEnabled(org.openqa.selenium.By by)
by - search conditionpublic org.openqa.selenium.WebElement untilDisabled(org.openqa.selenium.By by)
by - search conditionpublic org.openqa.selenium.WebElement until(org.openqa.selenium.By by,
org.hamcrest.Matcher<org.openqa.selenium.WebElement> matcher)
by - search conditionmatcher - the matching condition to checkMatchers,
Matcherpublic List<org.openqa.selenium.WebElement> untilCount(org.openqa.selenium.By by, org.hamcrest.Matcher<Integer> matcher)
by - search conditionmatcher - the matching condition to checkjava.util.List containing found elementsMatchers,
Matcherpublic List<org.openqa.selenium.WebElement> untilCount(org.openqa.selenium.By by, int count)
by - search conditioncount - the element count to matchjava.util.List containing found elementsMatchers,
MatcherCopyright © 2015. All rights reserved.