public class ExpectedConditions
extends java.lang.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<java.lang.Boolean> |
and(ExpectedCondition<?>... conditions)
An expectation with the logical and condition of the given list of conditions.
|
static ExpectedCondition<java.lang.Boolean> |
attributeContains(org.openqa.selenium.By locator,
java.lang.String attribute,
java.lang.String value)
An expectation for checking WebElement with given locator has attribute which contains specific
value
|
static ExpectedCondition<java.lang.Boolean> |
attributeContains(org.openqa.selenium.WebElement element,
java.lang.String attribute,
java.lang.String value)
An expectation for checking WebElement with given locator has attribute which contains specific
value
|
static ExpectedCondition<java.lang.Boolean> |
attributeToBe(org.openqa.selenium.By locator,
java.lang.String attribute,
java.lang.String value)
An expectation for checking WebElement with given locator has attribute with a specific value
|
static ExpectedCondition<java.lang.Boolean> |
attributeToBe(org.openqa.selenium.WebElement element,
java.lang.String attribute,
java.lang.String value)
An expectation for checking given WebElement has attribute with a specific value
|
static ExpectedCondition<java.lang.Boolean> |
attributeToBeNotEmpty(org.openqa.selenium.WebElement element,
java.lang.String attribute)
An expectation for checking WebElement any non empty value for given attribute
|
static ExpectedCondition<java.lang.Boolean> |
elementSelectionStateToBe(org.openqa.selenium.By locator,
boolean selected) |
static ExpectedCondition<java.lang.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<java.lang.Boolean> |
elementToBeSelected(org.openqa.selenium.By locator) |
static ExpectedCondition<java.lang.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(int frameLocator)
An expectation for checking whether the given frame is available to switch to.
|
static ExpectedCondition<org.openqa.selenium.WebDriver> |
frameToBeAvailableAndSwitchToIt(java.lang.String frameLocator)
An expectation for checking whether the given frame is available to switch to.
|
static ExpectedCondition<org.openqa.selenium.WebDriver> |
frameToBeAvailableAndSwitchToIt(org.openqa.selenium.WebElement frameLocator)
An expectation for checking whether the given frame is available to switch to.
|
static ExpectedCondition<java.lang.Boolean> |
invisibilityOf(org.openqa.selenium.WebElement element)
An expectation for checking the element to be invisible
|
static ExpectedCondition<java.lang.Boolean> |
invisibilityOfAllElements(java.util.List<org.openqa.selenium.WebElement> elements)
An expectation for checking all elements from given list to be invisible
|
static ExpectedCondition<java.lang.Boolean> |
invisibilityOfAllElements(org.openqa.selenium.WebElement... elements)
An expectation for checking all elements from given list to be invisible
|
static ExpectedCondition<java.lang.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<java.lang.Boolean> |
invisibilityOfElementWithText(org.openqa.selenium.By locator,
java.lang.String text)
An expectation for checking that an element with text is either invisible or not present on the
DOM.
|
static ExpectedCondition<java.lang.Boolean> |
javaScriptThrowsNoExceptions(java.lang.String javaScript)
An expectation to check if js executable.
|
static ExpectedCondition<java.lang.Object> |
jsReturnsValue(java.lang.String javaScript)
An expectation for String value from javascript
|
static ExpectedCondition<java.lang.Boolean> |
not(ExpectedCondition<?> condition)
An expectation with the logical opposite condition of the given condition.
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
numberOfElementsToBe(org.openqa.selenium.By locator,
java.lang.Integer number)
An expectation for checking number of WebElements with given locator
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
numberOfElementsToBeLessThan(org.openqa.selenium.By locator,
java.lang.Integer number)
An expectation for checking number of WebElements with given locator being less than defined
number
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
numberOfElementsToBeMoreThan(org.openqa.selenium.By locator,
java.lang.Integer number)
An expectation for checking number of WebElements with given locator
|
static ExpectedCondition<java.lang.Boolean> |
numberOfwindowsToBe(int expectedNumberOfWindows)
Deprecated.
please use
numberOfWindowsToBe(int) instead |
static ExpectedCondition<java.lang.Boolean> |
numberOfWindowsToBe(int expectedNumberOfWindows) |
static ExpectedCondition<java.lang.Boolean> |
or(ExpectedCondition<?>... conditions)
An expectation with the logical or condition of the given list of conditions.
|
static ExpectedCondition<java.util.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 ExpectedCondition<org.openqa.selenium.WebElement> |
presenceOfNestedElementLocatedBy(org.openqa.selenium.By locator,
org.openqa.selenium.By childLocator)
An expectation for checking child WebElement as a part of parent element to present
|
static ExpectedCondition<org.openqa.selenium.WebElement> |
presenceOfNestedElementLocatedBy(org.openqa.selenium.WebElement element,
org.openqa.selenium.By childLocator)
An expectation for checking child WebElement as a part of parent element to be present
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
presenceOfNestedElementsLocatedBy(org.openqa.selenium.By parent,
org.openqa.selenium.By childLocator)
An expectation for checking child WebElement as a part of parent element to present
|
static <T> ExpectedCondition<T> |
refreshed(ExpectedCondition<T> condition)
Wrapper for a condition, which allows for elements to update by redrawing.
|
static ExpectedCondition<java.lang.Boolean> |
stalenessOf(org.openqa.selenium.WebElement element)
Wait until an element is no longer attached to the DOM.
|
static ExpectedCondition<java.lang.Boolean> |
textMatches(org.openqa.selenium.By locator,
java.util.regex.Pattern pattern)
An expectation for checking WebElement with given locator has text with a value as a part of
it
|
static ExpectedCondition<java.lang.Boolean> |
textToBe(org.openqa.selenium.By locator,
java.lang.String value)
An expectation for checking WebElement with given locator has specific text
|
static ExpectedCondition<java.lang.Boolean> |
textToBePresentInElement(org.openqa.selenium.By locator,
java.lang.String text)
Deprecated.
Use
textToBePresentInElementLocated(By, String) instead |
static ExpectedCondition<java.lang.Boolean> |
textToBePresentInElement(org.openqa.selenium.WebElement element,
java.lang.String text)
An expectation for checking if the given text is present in the specified element.
|
static ExpectedCondition<java.lang.Boolean> |
textToBePresentInElementLocated(org.openqa.selenium.By locator,
java.lang.String text)
An expectation for checking if the given text is present in the element that matches the given
locator.
|
static ExpectedCondition<java.lang.Boolean> |
textToBePresentInElementValue(org.openqa.selenium.By locator,
java.lang.String text)
An expectation for checking if the given text is present in the specified elements value
attribute.
|
static ExpectedCondition<java.lang.Boolean> |
textToBePresentInElementValue(org.openqa.selenium.WebElement element,
java.lang.String text)
An expectation for checking if the given text is present in the specified elements value
attribute.
|
static ExpectedCondition<java.lang.Boolean> |
titleContains(java.lang.String title)
An expectation for checking that the title contains a case-sensitive substring
|
static ExpectedCondition<java.lang.Boolean> |
titleIs(java.lang.String title)
An expectation for checking the title of a page.
|
static ExpectedCondition<java.lang.Boolean> |
urlContains(java.lang.String fraction)
An expectation for the URL of the current page to contain specific text.
|
static ExpectedCondition<java.lang.Boolean> |
urlMatches(java.lang.String regex)
Expectation for the URL to match a specific regular expression
|
static ExpectedCondition<java.lang.Boolean> |
urlToBe(java.lang.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<java.util.List<org.openqa.selenium.WebElement>> |
visibilityOfAllElements(java.util.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<java.util.List<org.openqa.selenium.WebElement>> |
visibilityOfAllElements(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<java.util.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.
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
visibilityOfNestedElementsLocatedBy(org.openqa.selenium.By parent,
org.openqa.selenium.By childLocator)
An expectation for checking child WebElement as a part of parent element to be visible
|
static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> |
visibilityOfNestedElementsLocatedBy(org.openqa.selenium.WebElement element,
org.openqa.selenium.By childLocator)
An expectation for checking child WebElement as a part of parent element to be visible
|
public static ExpectedCondition<java.lang.Boolean> titleIs(java.lang.String title)
title
- the expected title, which must be an exact matchpublic static ExpectedCondition<java.lang.Boolean> titleContains(java.lang.String title)
title
- the fragment of title expectedpublic static ExpectedCondition<java.lang.Boolean> urlToBe(java.lang.String url)
url
- the url that the page should be ontrue
when the URL is what it should bepublic static ExpectedCondition<java.lang.Boolean> urlContains(java.lang.String fraction)
fraction
- the fraction of the url that the page should be ontrue
when the URL contains the textpublic static ExpectedCondition<java.lang.Boolean> urlMatches(java.lang.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<java.util.List<org.openqa.selenium.WebElement>> visibilityOfAllElementsLocatedBy(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> visibilityOfAllElements(org.openqa.selenium.WebElement... elements)
elements
- list of WebElementspublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> visibilityOfAllElements(java.util.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<java.util.List<org.openqa.selenium.WebElement>> presenceOfAllElementsLocatedBy(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<java.lang.Boolean> textToBePresentInElement(org.openqa.selenium.WebElement element, java.lang.String text)
element
- the WebElementtext
- to be present in the element@Deprecated public static ExpectedCondition<java.lang.Boolean> textToBePresentInElement(org.openqa.selenium.By locator, java.lang.String text)
textToBePresentInElementLocated(By, String)
insteadlocator
- used to find the elementtext
- to be present in the element found by the locatorpublic static ExpectedCondition<java.lang.Boolean> textToBePresentInElementLocated(org.openqa.selenium.By locator, java.lang.String text)
locator
- used to find the elementtext
- to be present in the element found by the locatorpublic static ExpectedCondition<java.lang.Boolean> textToBePresentInElementValue(org.openqa.selenium.WebElement element, java.lang.String text)
element
- the WebElementtext
- to be present in the element's value attributepublic static ExpectedCondition<java.lang.Boolean> textToBePresentInElementValue(org.openqa.selenium.By locator, java.lang.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(java.lang.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<org.openqa.selenium.WebDriver> frameToBeAvailableAndSwitchToIt(int frameLocator)
If the frame is available it switches the given driver to the specified frameIndex.
frameLocator
- used to find the frame (index)public static ExpectedCondition<org.openqa.selenium.WebDriver> frameToBeAvailableAndSwitchToIt(org.openqa.selenium.WebElement frameLocator)
If the frame is available it switches the given driver to the specified webelement.
frameLocator
- used to find the frame (webelement)public static ExpectedCondition<java.lang.Boolean> invisibilityOfElementLocated(org.openqa.selenium.By locator)
locator
- used to find the elementpublic static ExpectedCondition<java.lang.Boolean> invisibilityOfElementWithText(org.openqa.selenium.By locator, java.lang.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<java.lang.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.T
- return type of the condition providedcondition
- ExpectedCondition to wrappublic static ExpectedCondition<java.lang.Boolean> elementToBeSelected(org.openqa.selenium.WebElement element)
element
- WebElement to be selectedpublic static ExpectedCondition<java.lang.Boolean> elementSelectionStateToBe(org.openqa.selenium.WebElement element, boolean selected)
element
- WebElement to be selectedselected
- boolean state of the selection state of the elementpublic static ExpectedCondition<java.lang.Boolean> elementToBeSelected(org.openqa.selenium.By locator)
public static ExpectedCondition<java.lang.Boolean> elementSelectionStateToBe(org.openqa.selenium.By locator, boolean selected)
public static ExpectedCondition<org.openqa.selenium.Alert> alertIsPresent()
@Deprecated public static ExpectedCondition<java.lang.Boolean> numberOfwindowsToBe(int expectedNumberOfWindows)
numberOfWindowsToBe(int)
insteadpublic static ExpectedCondition<java.lang.Boolean> numberOfWindowsToBe(int expectedNumberOfWindows)
public static ExpectedCondition<java.lang.Boolean> not(ExpectedCondition<?> condition)
condition
- ExpectedCondition to be invertedpublic static ExpectedCondition<java.lang.Boolean> attributeToBe(org.openqa.selenium.By locator, java.lang.String attribute, java.lang.String value)
locator
- used to find the elementattribute
- used to define css or html attributevalue
- used as expected attribute valuepublic static ExpectedCondition<java.lang.Boolean> textToBe(org.openqa.selenium.By locator, java.lang.String value)
locator
- used to find the elementvalue
- used as expected textpublic static ExpectedCondition<java.lang.Boolean> textMatches(org.openqa.selenium.By locator, java.util.regex.Pattern pattern)
locator
- used to find the elementpattern
- used as expected text matcher patternpublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> numberOfElementsToBeMoreThan(org.openqa.selenium.By locator, java.lang.Integer number)
locator
- used to find the elementnumber
- used to define exact number of elementspublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> numberOfElementsToBeLessThan(org.openqa.selenium.By locator, java.lang.Integer number)
locator
- used to find the elementnumber
- used to define maximum number of elementspublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> numberOfElementsToBe(org.openqa.selenium.By locator, java.lang.Integer number)
locator
- used to find the elementnumber
- used to define number of elementspublic static ExpectedCondition<java.lang.Boolean> attributeToBe(org.openqa.selenium.WebElement element, java.lang.String attribute, java.lang.String value)
element
- used to check its parametersattribute
- used to define css or html attributevalue
- used as expected attribute valuepublic static ExpectedCondition<java.lang.Boolean> attributeContains(org.openqa.selenium.WebElement element, java.lang.String attribute, java.lang.String value)
element
- used to check its parametersattribute
- used to define css or html attributevalue
- used as expected attribute valuepublic static ExpectedCondition<java.lang.Boolean> attributeContains(org.openqa.selenium.By locator, java.lang.String attribute, java.lang.String value)
locator
- used to define WebElement to check its parametersattribute
- used to define css or html attributevalue
- used as expected attribute valuepublic static ExpectedCondition<java.lang.Boolean> attributeToBeNotEmpty(org.openqa.selenium.WebElement element, java.lang.String attribute)
element
- used to check its parametersattribute
- used to define css or html attributepublic static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> visibilityOfNestedElementsLocatedBy(org.openqa.selenium.By parent, org.openqa.selenium.By childLocator)
parent
- used to check parent element. For example table with locator
By.id("fish")childLocator
- used to find the ultimate child element.public static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> visibilityOfNestedElementsLocatedBy(org.openqa.selenium.WebElement element, org.openqa.selenium.By childLocator)
element
- used as parent element. For example table with locator By.xpath("//table")childLocator
- used to find child element. For example td By.xpath("./tr/td")public static ExpectedCondition<org.openqa.selenium.WebElement> presenceOfNestedElementLocatedBy(org.openqa.selenium.By locator, org.openqa.selenium.By childLocator)
locator
- used to check parent element. For example table with locator
By.xpath("//table")childLocator
- used to find child element. For example td By.xpath("./tr/td")public static ExpectedCondition<org.openqa.selenium.WebElement> presenceOfNestedElementLocatedBy(org.openqa.selenium.WebElement element, org.openqa.selenium.By childLocator)
element
- used as parent elementchildLocator
- used to find child element. For example td By.xpath("./tr/td")public static ExpectedCondition<java.util.List<org.openqa.selenium.WebElement>> presenceOfNestedElementsLocatedBy(org.openqa.selenium.By parent, org.openqa.selenium.By childLocator)
parent
- used to check parent element. For example table with locator
By.xpath("//table")childLocator
- used to find child element. For example td By.xpath("./tr/td")public static ExpectedCondition<java.lang.Boolean> invisibilityOfAllElements(org.openqa.selenium.WebElement... elements)
elements
- used to check their invisibilitypublic static ExpectedCondition<java.lang.Boolean> invisibilityOfAllElements(java.util.List<org.openqa.selenium.WebElement> elements)
elements
- used to check their invisibilitypublic static ExpectedCondition<java.lang.Boolean> invisibilityOf(org.openqa.selenium.WebElement element)
element
- used to check its invisibilitypublic static ExpectedCondition<java.lang.Boolean> or(ExpectedCondition<?>... conditions)
conditions
- ExpectedCondition is a list of alternative conditionspublic static ExpectedCondition<java.lang.Boolean> and(ExpectedCondition<?>... conditions)
conditions
- ExpectedCondition is a list of alternative conditionspublic static ExpectedCondition<java.lang.Boolean> javaScriptThrowsNoExceptions(java.lang.String javaScript)
javaScript
- used as executable scriptpublic static ExpectedCondition<java.lang.Object> jsReturnsValue(java.lang.String javaScript)
javaScript
- as executable js line