class WebDriverExpectedCondition (View source)

Canned ExpectedConditions which are generally useful within webdriver tests.

Methods

__construct(callable $apply)

No description

callable
getApply()

No description

static WebDriverExpectedCondition<bool>
titleIs(string $title)

An expectation for checking the title of a page.

static WebDriverExpectedCondition<bool>
titleContains(string $title)

An expectation for checking substring of a page Title.

static WebDriverExpectedCondition<bool>
titleMatches(string $titleRegexp)

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

static WebDriverExpectedCondition<bool>
urlIs(string $url)

An expectation for checking the URL of a page.

static WebDriverExpectedCondition<bool>
urlContains(string $url)

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

static WebDriverExpectedCondition<bool>
urlMatches(string $urlRegexp)

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

static WebDriverElement>
presenceOfElementLocated(WebDriverBy $by)

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

static WebDriverExpectedCondition<array>
presenceOfAllElementsLocatedBy(WebDriverBy $by)

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

static WebDriverElement>
visibilityOfElementLocated(WebDriverBy $by)

An expectation for checking that an element is present on the DOM of a page 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.

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

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

static WebDriverExpectedCondition<bool>
elementTextContains(WebDriverBy $by, string $text)

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

static WebDriverExpectedCondition<bool>
elementTextIs(WebDriverBy $by, string $text)

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

static WebDriverExpectedCondition<bool>
elementTextMatches(WebDriverBy $by, string $regexp)

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

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

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

static WebDriverExpectedCondition<bool>
elementValueContains(WebDriverBy $by, string $text)

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

static WebDriver|bool>
frameToBeAvailableAndSwitchToIt(string $frame_locator)

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

static WebDriverExpectedCondition<bool>
invisibilityOfElementLocated(WebDriverBy $by)

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

static WebDriverExpectedCondition<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 WebDriverExpectedCondition<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 WebDriverExpectedCondition<bool>
elementToBeSelected(mixed $element_or_by)

An expectation for checking if the given element is selected.

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

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

WebDriverExpectedCondition<bool>

Condition returns whether current page title equals given string.

static WebDriverExpectedCondition<bool> titleContains(string $title)

An expectation for checking substring of a page Title.

Parameters

string $title

The expected substring of Title.

Return Value

WebDriverExpectedCondition<bool>

Condition returns whether current page title contains given string.

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

Condition returns whether current page title matches the regular expression.

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

Condition returns whether current URL equals given one.

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

Condition returns whether current URL contains given string.

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

Condition returns whether current URL matches the regular expression.

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>

Condition returns the element which is located.

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>

Condition returns an array of WebDriverElements once they are 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>

Condition returns 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>

Condition returns the same WebDriverElement once it is visible.

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

Condition returns whether the text is present in the element.

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

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

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

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

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

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

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

Condition returns whether the text is present in value attribute.

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

Condition returns whether the text is present in value attribute.

static WebDriver|bool> 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|bool>

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

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

WebDriverExpectedCondition<bool>

Condition returns whether no visible element located.

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

WebDriverExpectedCondition<bool>

Condition returns 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>

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

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

WebDriverExpectedCondition<bool>

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

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>

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

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

WebDriverExpectedCondition<bool>

Condition returns whether the element is selected.

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

WebDriverExpectedCondition<bool>

Condition returns whether the element is selected.

static WebDriverAlert> alertIsPresent()

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

Return Value

WebDriverAlert>

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.