public class ExpectedConditions extends Object
ExpectedCondition
s which are generally useful within webdriver
tests.Modifier and Type | Method and Description |
---|---|
static ExpectedCondition<org.openqa.selenium.Alert> |
alertIsPresent() |
static ExpectedCondition<Boolean> |
elementSelectionStateToBe(org.openqa.selenium.By locator,
boolean selected) |
static ExpectedCondition<Boolean> |
elementSelectionStateToBe(org.openqa.selenium.WebElement element,
boolean selected)
An expectation for checking if the given element is selected.
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
elementToBeClickable(org.openqa.selenium.By locator)
An expectation for checking an element is visible and enabled such that you
can click it.
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
elementToBeClickable(org.openqa.selenium.WebElement element)
An expectation for checking an element is visible and enabled such that you
can click it.
|
static ExpectedCondition<Boolean> |
elementToBeSelected(org.openqa.selenium.By locator) |
static ExpectedCondition<Boolean> |
elementToBeSelected(org.openqa.selenium.WebElement element)
An expectation for checking if the given element is selected.
|
static ExpectedCondition<org.openqa.selenium.WebDriver> |
frameToBeAvailableAndSwitchToIt(org.openqa.selenium.By locator)
An expectation for checking whether the given frame is available to switch
to.
|
static ExpectedCondition<org.openqa.selenium.WebDriver> |
frameToBeAvailableAndSwitchToIt(String frameLocator)
An expectation for checking whether the given frame is available to switch
to.
|
static ExpectedCondition<Boolean> |
invisibilityOfElementLocated(org.openqa.selenium.By locator)
An expectation for checking that an element is either invisible or not
present on the DOM.
|
static ExpectedCondition<Boolean> |
invisibilityOfElementWithText(org.openqa.selenium.By locator,
String text)
An expectation for checking that an element with text is either invisible
or not present on the DOM.
|
static ExpectedCondition<Boolean> |
not(ExpectedCondition<?> condition)
An expectation with the logical opposite condition of the given condition.
|
static ExpectedCondition<List<org.openqa.selenium.WebElement>> |
presenceOfAllElementsLocatedBy(org.openqa.selenium.By locator)
An expectation for checking that there is at least one element present on a
web page.
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
presenceOfElementLocated(org.openqa.selenium.By locator)
An expectation for checking that an element is present on the DOM of a
page.
|
static <T> ExpectedCondition<T> |
refreshed(ExpectedCondition<T> condition)
Wrapper for a condition, which allows for elements to update by redrawing.
|
static ExpectedCondition<Boolean> |
stalenessOf(org.openqa.selenium.WebElement element)
Wait until an element is no longer attached to the DOM.
|
static ExpectedCondition<Boolean> |
textToBePresentInElement(org.openqa.selenium.By locator,
String text)
Deprecated.
Use
textToBePresentInElementLocated(By, String) instead |
static ExpectedCondition<Boolean> |
textToBePresentInElement(org.openqa.selenium.WebElement element,
String text)
An expectation for checking if the given text is present in the specified element.
|
static ExpectedCondition<Boolean> |
textToBePresentInElementLocated(org.openqa.selenium.By locator,
String text)
An expectation for checking if the given text is present in the element that matches
the given locator.
|
static ExpectedCondition<Boolean> |
textToBePresentInElementValue(org.openqa.selenium.By locator,
String text)
An expectation for checking if the given text is present in the specified
elements value attribute.
|
static ExpectedCondition<Boolean> |
textToBePresentInElementValue(org.openqa.selenium.WebElement element,
String text)
An expectation for checking if the given text is present in the specified
elements value attribute.
|
static ExpectedCondition<Boolean> |
titleContains(String title)
An expectation for checking that the title contains a case-sensitive
substring
|
static ExpectedCondition<Boolean> |
titleIs(String title)
An expectation for checking the title of a page.
|
static ExpectedCondition<Boolean> |
urlContains(String fraction)
An expectation for the URL of the current page to contain specific text.
|
static ExpectedCondition<Boolean> |
urlMatches(String regex)
Expectation for the URL to match a specific regular expression
|
static ExpectedCondition<Boolean> |
urlToBe(String url)
An expectation for the URL of the current page to be a specific url.
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
visibilityOf(org.openqa.selenium.WebElement element)
An expectation for checking that an element, known to be present on the DOM
of a page, is visible.
|
static ExpectedCondition<List<org.openqa.selenium.WebElement>> |
visibilityOfAllElements(List<org.openqa.selenium.WebElement> elements)
An expectation for checking that all elements present on the web page that
match the locator are visible.
|
static ExpectedCondition<List<org.openqa.selenium.WebElement>> |
visibilityOfAllElementsLocatedBy(org.openqa.selenium.By locator)
An expectation for checking that all elements present on the web page that
match the locator are visible.
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
visibilityOfElementLocated(org.openqa.selenium.By locator)
An expectation for checking that an element is present on the DOM of a page
and visible.
|
public static ExpectedCondition<Boolean> titleIs(String title)
title
- the expected title, which must be an exact matchpublic static ExpectedCondition<Boolean> titleContains(String title)
title
- the fragment of title expectedpublic static ExpectedCondition<Boolean> urlToBe(String url)
url
- the url that the page should be ontrue
when the URL is what it should bepublic static ExpectedCondition<Boolean> urlContains(String fraction)
fraction
- the fraction of the url that the page should be ontrue
when the URL contains the textpublic static ExpectedCondition<Boolean> urlMatches(String regex)
regex
- the regular expression that the URL should matchtrue
if the URL matches the specified regular expressionpublic static ExpectedCondition<org.openqa.selenium.WebElement> presenceOfElementLocated(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<org.openqa.selenium.WebElement> visibilityOfElementLocated(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<List<org.openqa.selenium.WebElement>> visibilityOfAllElementsLocatedBy(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<List<org.openqa.selenium.WebElement>> visibilityOfAllElements(List<org.openqa.selenium.WebElement> elements)
elements
- list of WebElementspublic static ExpectedCondition<org.openqa.selenium.WebElement> visibilityOf(org.openqa.selenium.WebElement element)
element
- the WebElementpublic static ExpectedCondition<List<org.openqa.selenium.WebElement>> presenceOfAllElementsLocatedBy(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<Boolean> textToBePresentInElement(org.openqa.selenium.WebElement element, String text)
element
- the WebElementtext
- to be present in the element@Deprecated public static ExpectedCondition<Boolean> textToBePresentInElement(org.openqa.selenium.By locator, String text)
textToBePresentInElementLocated(By, String)
insteadlocator
- used to find the elementtext
- to be present in the element found by the locatorpublic static ExpectedCondition<Boolean> textToBePresentInElementLocated(org.openqa.selenium.By locator, String text)
locator
- used to find the elementtext
- to be present in the element found by the locatorpublic static ExpectedCondition<Boolean> textToBePresentInElementValue(org.openqa.selenium.WebElement element, String text)
element
- the WebElementtext
- to be present in the element's value attributepublic static ExpectedCondition<Boolean> textToBePresentInElementValue(org.openqa.selenium.By locator, String text)
locator
- used to find the elementtext
- to be present in the value attribute of the element found by the locatorpublic static ExpectedCondition<org.openqa.selenium.WebDriver> frameToBeAvailableAndSwitchToIt(String frameLocator)
If the frame is available it switches the given driver to the specified frame.
frameLocator
- used to find the frame (id or name)public static ExpectedCondition<org.openqa.selenium.WebDriver> frameToBeAvailableAndSwitchToIt(org.openqa.selenium.By locator)
If the frame is available it switches the given driver to the specified frame.
locator
- used to find the framepublic static ExpectedCondition<Boolean> invisibilityOfElementLocated(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<Boolean> invisibilityOfElementWithText(org.openqa.selenium.By locator, String text)
locator
- used to find the elementtext
- of the elementpublic static ExpectedCondition<org.openqa.selenium.WebElement> elementToBeClickable(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<org.openqa.selenium.WebElement> elementToBeClickable(org.openqa.selenium.WebElement element)
element
- the WebElementpublic static ExpectedCondition<Boolean> stalenessOf(org.openqa.selenium.WebElement element)
element
- The element to wait for.public static <T> ExpectedCondition<T> refreshed(ExpectedCondition<T> condition)
StaleElementReferenceException
is
thrown when the second part of the condition is checked.public static ExpectedCondition<Boolean> elementToBeSelected(org.openqa.selenium.WebElement element)
public static ExpectedCondition<Boolean> elementSelectionStateToBe(org.openqa.selenium.WebElement element, boolean selected)
public static ExpectedCondition<Boolean> elementToBeSelected(org.openqa.selenium.By locator)
public static ExpectedCondition<Boolean> elementSelectionStateToBe(org.openqa.selenium.By locator, boolean selected)
public static ExpectedCondition<org.openqa.selenium.Alert> alertIsPresent()
public static ExpectedCondition<Boolean> not(ExpectedCondition<?> condition)
Copyright © 2015. All rights reserved.