org.openqa.selenium.support.ui
Class ExpectedConditions

java.lang.Object
  extended by org.openqa.selenium.support.ui.ExpectedConditions

public class ExpectedConditions
extends java.lang.Object

Canned ExpectedConditions which are generally useful within webdriver tests.


Method Summary
static ExpectedCondition<WebElement> elementToBeClickable(By locator)
          An Expectation for checking an element is visible and enabled such that you can click it.
static ExpectedCondition<WebDriver> frameToBeAvailableAndSwitchToIt(java.lang.String frameLocator)
          An expectation for checking whether the given frame is available to switch to.
static ExpectedCondition<java.lang.Boolean> invisibilityOfElementLocated(By locator)
          An Expectation for checking that an element is either invisible or not present on the DOM.
static ExpectedCondition<java.util.List<WebElement>> presenceOfAllElementsLocatedBy(By locator)
          An expectation for checking that there is at least one element present on a web page.
static ExpectedCondition<WebElement> presenceOfElementLocated(By locator)
          An expectation for checking that an element is present on the DOM of a page.
static ExpectedCondition<java.lang.Boolean> stalenessOf(WebElement element)
          Wait until an element is no longer attached to the DOM.
static ExpectedCondition<java.lang.Boolean> textToBePresentInElement(By locator, java.lang.String text)
          An expectation for checking if the given text is present in the specified element.
static ExpectedCondition<java.lang.Boolean> textToBePresentInElementValue(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> 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<WebElement> visibilityOf(WebElement element)
          An expectation for checking that an element, known to be present on the DOM of a page, is visible.
static ExpectedCondition<WebElement> visibilityOfElementLocated(By locator)
          An expectation for checking that an element is present on the DOM of a page and visible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

titleIs

public static ExpectedCondition<java.lang.Boolean> titleIs(java.lang.String title)
An expectation for checking the title of a page.

Parameters:
title - the expected title, which must be an exact match
Returns:
true when the title matches, false otherwise

titleContains

public static ExpectedCondition<java.lang.Boolean> titleContains(java.lang.String title)
An expectation for checking that the title contains a case-sensitive substring

Parameters:
title - the fragment of title expected
Returns:
true when the title matches, false otherwise

presenceOfElementLocated

public static ExpectedCondition<WebElement> presenceOfElementLocated(By locator)
An expectation for checking that an element is present on the DOM of a page. This does not necessarily mean that the element is visible.

Parameters:
locator - used to find the element
Returns:
the WebElement once it is located

visibilityOfElementLocated

public static ExpectedCondition<WebElement> visibilityOfElementLocated(By locator)
An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

Parameters:
locator - used to find the element
Returns:
the WebElement once it is located and visible

visibilityOf

public static ExpectedCondition<WebElement> visibilityOf(WebElement element)
An expectation for checking that an element, known to be present on the DOM of a page, is visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

Parameters:
element - the WebElement
Returns:
the (same) WebElement once it is visible

presenceOfAllElementsLocatedBy

public static ExpectedCondition<java.util.List<WebElement>> presenceOfAllElementsLocatedBy(By locator)
An expectation for checking that there is at least one element present on a web page.

Parameters:
locator - used to find the element
Returns:
the list of WebElements once they are located

textToBePresentInElement

public static ExpectedCondition<java.lang.Boolean> textToBePresentInElement(By locator,
                                                                            java.lang.String text)
An expectation for checking if the given text is present in the specified element.


textToBePresentInElementValue

public static ExpectedCondition<java.lang.Boolean> textToBePresentInElementValue(By locator,
                                                                                 java.lang.String text)
An expectation for checking if the given text is present in the specified elements value attribute.


frameToBeAvailableAndSwitchToIt

public static ExpectedCondition<WebDriver> frameToBeAvailableAndSwitchToIt(java.lang.String frameLocator)
An expectation for checking whether the given frame is available to switch to.

If the frame is available it switches the given driver to the specified frame.


invisibilityOfElementLocated

public static ExpectedCondition<java.lang.Boolean> invisibilityOfElementLocated(By locator)
An Expectation for checking that an element is either invisible or not present on the DOM.

Parameters:
locator - used to find the element

elementToBeClickable

public static ExpectedCondition<WebElement> elementToBeClickable(By locator)
An Expectation for checking an element is visible and enabled such that you can click it.


stalenessOf

public static ExpectedCondition<java.lang.Boolean> stalenessOf(WebElement element)
Wait until an element is no longer attached to the DOM.

Parameters:
element - The element to wait for.
Returns:
false is the element is still attached to the DOM, true otherwise.


Copyright © 2011. All Rights Reserved.