class WebDriverExpectedCondition (View source)

Canned ExpectedConditions which are generally useful within webdriver tests.

Methods

__construct(callable $apply)

No description

callable
getApply()

No description

titleIs(string $title)

An expectation for checking the title of a page.

titleContains(string $title)

An expectation for checking substring of a page Title.

titleMatches(string $titleRegexp)

An expectation for checking current page title matches the given regular expression.

urlIs(string $url)

An expectation for checking the URL of a page.

urlContains(string $url)

An expectation for checking substring of the URL of a page.

urlMatches(string $urlRegexp)

An expectation for checking current page URL matches the given regular expression.

presenceOfElementLocated(WebDriverBy $by)

An expectation for checking that an element is present on the DOM of a page.

presenceOfAllElementsLocatedBy(WebDriverBy $by)

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

visibilityOfElementLocated(WebDriverBy $by)

An expectation for checking that an element is present on the DOM of a page and visible.

visibilityOfAnyElementLocated(WebDriverBy $by)

An expectation for checking than at least one element in an array of elements is present on the DOM of a page and visible.

visibilityOf(WebDriverElement $element)

An expectation for checking that an element, known to be present on the DOM of a page, is visible.

textToBePresentInElement(WebDriverBy $by, string $text) deprecated

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

elementTextContains(WebDriverBy $by, string $text)

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

elementTextIs(WebDriverBy $by, string $text)

An expectation for checking if the given text exactly equals the text in specified element.

elementTextMatches(WebDriverBy $by, string $regexp)

An expectation for checking if the given regular expression matches the text in specified element.

textToBePresentInElementValue(WebDriverBy $by, string $text) deprecated

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

elementValueContains(WebDriverBy $by, string $text)

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

frameToBeAvailableAndSwitchToIt(string $frame_locator)

Expectation for checking if iFrame exists. If iFrame exists switches driver's focus to the iFrame.

invisibilityOfElementLocated(WebDriverBy $by)

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

invisibilityOfElementWithText(WebDriverBy $by, string $text)

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

elementToBeClickable(WebDriverBy $by)

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

stalenessOf(WebDriverElement $element)

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

refreshed(WebDriverExpectedCondition $condition)

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

elementToBeSelected(mixed $element_or_by)

An expectation for checking if the given element is selected.

elementSelectionStateToBe(mixed $element_or_by, bool $selected)

An expectation for checking if the given element is selected.

alertIsPresent()

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

numberOfWindowsToBe(int $expectedNumberOfWindows)

An expectation checking the number of opened windows.

static mixed
not(WebDriverExpectedCondition $condition)

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

Details

protected __construct(callable $apply)

No description

Parameters

callable $apply

callable getApply()

No description

Return Value

callable

A callable function to be executed by WebDriverWait

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns whether current page title equals given string.

static WebDriverExpectedCondition titleContains(string $title)

An expectation for checking substring of a page Title.

Parameters

string $title

The expected substring of Title.

Return Value

WebDriverExpectedCondition

Condition returns whether current page title contains given string.

static WebDriverExpectedCondition titleMatches(string $titleRegexp)

An expectation for checking current page title matches the given regular expression.

Parameters

string $titleRegexp

The regular expression to test against.

Return Value

WebDriverExpectedCondition

Condition returns whether current page title matches the regular expression.

static WebDriverExpectedCondition urlIs(string $url)

An expectation for checking the URL of a page.

Parameters

string $url

The expected URL, which must be an exact match.

Return Value

WebDriverExpectedCondition

Condition returns whether current URL equals given one.

static WebDriverExpectedCondition urlContains(string $url)

An expectation for checking substring of the URL of a page.

Parameters

string $url

The expected substring of the URL

Return Value

WebDriverExpectedCondition

Condition returns whether current URL contains given string.

static WebDriverExpectedCondition urlMatches(string $urlRegexp)

An expectation for checking current page URL matches the given regular expression.

Parameters

string $urlRegexp

The regular expression to test against.

Return Value

WebDriverExpectedCondition

Condition returns whether current URL matches the regular expression.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns the WebDriverElement which is located.

static WebDriverExpectedCondition 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

Condition return an array of WebDriverElement once they are located.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns the WebDriverElement which is located and visible.

static WebDriverExpectedCondition visibilityOfAnyElementLocated(WebDriverBy $by)

An expectation for checking than at least one element in an array of elements 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 located used to find the element.

Return Value

WebDriverExpectedCondition

Condition returns the array of WebDriverElement that are located and visible.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns the same WebDriverElement once it is visible.

static WebDriverExpectedCondition textToBePresentInElement(WebDriverBy $by, string $text) deprecated

deprecated Use WebDriverExpectedCondition::elementTextContains() instead

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

To check exact text match use elementTextIs() condition.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The text to be presented in the element.

Return Value

WebDriverExpectedCondition

Condition returns whether the text is present in the element.

static WebDriverExpectedCondition elementTextContains(WebDriverBy $by, string $text)

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

To check exact text match use elementTextIs() condition.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The text to be presented in the element.

Return Value

WebDriverExpectedCondition

Condition returns whether the partial text is present in the element.

static WebDriverExpectedCondition elementTextIs(WebDriverBy $by, string $text)

An expectation for checking if the given text exactly equals the text in specified element.

To check only partial substring of the text use elementTextContains() condition.

Parameters

WebDriverBy $by

The locator used to find the element.

string $text

The expected text of the element.

Return Value

WebDriverExpectedCondition

Condition returns whether the element has text value equal to given one.

static WebDriverExpectedCondition elementTextMatches(WebDriverBy $by, string $regexp)

An expectation for checking if the given regular expression matches the text in specified element.

Parameters

WebDriverBy $by

The locator used to find the element.

string $regexp

The regular expression to test against.

Return Value

WebDriverExpectedCondition

Condition returns whether the element has text value equal to given one.

static WebDriverExpectedCondition textToBePresentInElementValue(WebDriverBy $by, string $text) deprecated

deprecated Use WebDriverExpectedCondition::elementValueContains() instead

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

WebDriverExpectedCondition

Condition returns whether the text is present in value attribute.

static WebDriverExpectedCondition elementValueContains(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

WebDriverExpectedCondition

Condition returns whether the text is present in value attribute.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns object focused on new frame when frame is found, false otherwise.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns whether no visible element located.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns whether the text is found in the element located.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition return the WebDriverElement once it is located, visible and clickable.

static WebDriverExpectedCondition stalenessOf(WebDriverElement $element)

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

Parameters

WebDriverElement $element

The element to wait for.

Return Value

WebDriverExpectedCondition

Condition returns whether the element is still attached to the DOM.

static WebDriverExpectedCondition 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

Condition returns the return value of the getApply() of the given condition.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns whether the element is selected.

static WebDriverExpectedCondition 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

WebDriverExpectedCondition

Condition returns whether the element is selected.

static WebDriverExpectedCondition alertIsPresent()

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

Return Value

WebDriverExpectedCondition

Condition returns WebDriverAlert if alert() is present, null otherwise.

static WebDriverExpectedCondition numberOfWindowsToBe(int $expectedNumberOfWindows)

An expectation checking the number of opened windows.

Parameters

int $expectedNumberOfWindows

Return Value

WebDriverExpectedCondition

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.