class WebDriverExpectedCondition (View source)

Canned ExpectedConditions which are generally useful within webdriver tests.

Methods

getApply()

No description

__construct($apply)

No description

static bool
titleIs(string $title)

An expectation for checking the title of a page.

static bool
titleContains(string $title)

An expectation for checking substring of a page Title.

static WebDriverElement>
presenceOfElementLocated(WebDriverBy $by)

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.

static WebDriverElement>
visibilityOfElementLocated(WebDriverBy $by)

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.

static WebDriverElement>
visibilityOf(WebDriverElement $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.

static WebDriverExpectedCondition<array>
presenceOfAllElementsLocatedBy(WebDriverBy $by)

An expectation for checking that there is at least one element present on a web page.

static bool
textToBePresentInElement(WebDriverBy $by, string $text)

An expectation for checking if the given text is present in the specified element.

static bool
textToBePresentInElementValue(WebDriverBy $by, string $text)

An expectation for checking if the given text is present in the specified elements value attribute.

static WebDriver>
frameToBeAvailableAndSwitchToIt(string $frame_locator)

Expectation for checking if iFrame exists.

static bool
invisibilityOfElementLocated(WebDriverBy $by)

An expectation for checking that an element is either invisible or not present on the DOM.

static bool
invisibilityOfElementWithText(WebDriverBy $by, string $text)

An expectation for checking that an element with text is either invisible or not present on the DOM.

static WebDriverElement>
elementToBeClickable(WebDriverBy $by)

An expectation for checking an element is visible and enabled such that you can click it.

static bool
stalenessOf(WebDriverElement $element)

Wait until an element is no longer attached to the DOM.

static WebDriverExpectedCondition<mixed>
refreshed(WebDriverExpectedCondition $condition)

Wrapper for a condition, which allows for elements to update by redrawing.

static bool
elementToBeSelected(mixed $element_or_by)

An expectation for checking if the given element is selected.

static bool
elementSelectionStateToBe(mixed $element_or_by, bool $selected)

An expectation for checking if the given element is selected.

static WebDriverAlert>
alertIsPresent()

An expectation for whether an alert() box is present.

static mixed
not(WebDriverExpectedCondition $condition)

An expectation with the logical opposite condition of the given condition.

Details

getApply()

No description

protected __construct($apply)

No description

Parameters

$apply

static bool titleIs(string $title)

An expectation for checking the title of a page.

Parameters

string $title

The expected title, which must be an exact match.

Return Value

bool

WebDriverExpectedCondition True when the title matches, false otherwise.

static bool titleContains(string $title)

An expectation for checking substring of a page Title.

Parameters

string $title

The expected substring of Title.

Return Value

bool

WebDriverExpectedCondition True when in title, false otherwise.

static WebDriverElement> presenceOfElementLocated(WebDriverBy $by)

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

WebDriverBy $by

The locator used to find the element.

Return Value

WebDriverElement>

The element which is located.

static WebDriverElement> visibilityOfElementLocated(WebDriverBy $by)

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

WebDriverBy $by

The locator used to find the element.

Return Value

WebDriverElement>

The element which is located and visible.

static WebDriverElement> visibilityOf(WebDriverElement $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

WebDriverElement $element

The element to be checked.

Return Value

WebDriverElement>

The same WebDriverElement once it is visible.

static WebDriverExpectedCondition<array> presenceOfAllElementsLocatedBy(WebDriverBy $by)

An expectation for checking that there is at least one element present on a web page.

Parameters

WebDriverBy $by

The locator used to find the element.

Return Value

WebDriverExpectedCondition<array>

An array of WebDriverElements once they are located.

static bool textToBePresentInElement(WebDriverBy $by, string $text)

An expectation for checking if the given text is present in the specified element.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The text to be presented in the element.

Return Value

bool

WebDriverExpectedCondition Whether the text is presented.

static bool textToBePresentInElementValue(WebDriverBy $by, string $text)

An expectation for checking if the given text is present in the specified elements value attribute.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The text to be presented in the element value.

Return Value

bool

WebDriverExpectedCondition Whether the text is presented.

static WebDriver> frameToBeAvailableAndSwitchToIt(string $frame_locator)

Expectation for checking if iFrame exists.

If iFrame exists switches driver's focus to the iFrame

Parameters

string $frame_locator

The locator used to find the iFrame expected to be either the id or name value of the i/frame

Return Value

WebDriver>

object focused on new frame when frame is found bool false otherwise

static bool invisibilityOfElementLocated(WebDriverBy $by)

An expectation for checking that an element is either invisible or not present on the DOM.

Parameters

WebDriverBy $by

The locator used to find the element.

Return Value

bool

WebDriverExpectedCondition Whether there is no element located.

static bool invisibilityOfElementWithText(WebDriverBy $by, string $text)

An expectation for checking that an element with text is either invisible or not present on the DOM.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The text of the element.

Return Value

bool

WebDriverExpectedCondition Whether the text is found in the element located.

static WebDriverElement> elementToBeClickable(WebDriverBy $by)

An expectation for checking an element is visible and enabled such that you can click it.

Parameters

WebDriverBy $by

The locator used to find the element

Return Value

WebDriverElement>

The WebDriverElement once it is located, visible and clickable

static bool stalenessOf(WebDriverElement $element)

Wait until an element is no longer attached to the DOM.

Parameters

WebDriverElement $element

The element to wait for.

Return Value

bool

WebDriverExpectedCondition false if the element is still attached to the DOM, true otherwise.

static WebDriverExpectedCondition<mixed> refreshed(WebDriverExpectedCondition $condition)

Wrapper for a condition, which allows for elements to update by redrawing.

This works around the problem of conditions which have two parts: find an element and then check for some condition on it. For these conditions it is possible that an element is located and then subsequently it is redrawn on the client. When this happens a StaleElementReferenceException is thrown when the second part of the condition is checked.

Parameters

WebDriverExpectedCondition $condition

The condition wrapped.

Return Value

WebDriverExpectedCondition<mixed>

The return value of the getApply() of the given condition.

static bool elementToBeSelected(mixed $element_or_by)

An expectation for checking if the given element is selected.

Parameters

mixed $element_or_by

Either the element or the locator.

Return Value

bool

WebDriverExpectedCondition whether the element is selected.

static bool elementSelectionStateToBe(mixed $element_or_by, bool $selected)

An expectation for checking if the given element is selected.

Parameters

mixed $element_or_by

Either the element or the locator.

bool $selected

The required state.

Return Value

bool

WebDriverExpectedCondition Whether the element is selected.

static WebDriverAlert> alertIsPresent()

An expectation for whether an alert() box is present.

Return Value

WebDriverAlert>

if alert() is present, null otherwise.

static mixed not(WebDriverExpectedCondition $condition)

An expectation with the logical opposite condition of the given condition.

Parameters

WebDriverExpectedCondition $condition

The condition to be negated.

Return Value

mixed

The negation of the result of the given condition.