HumHub Documentation (unofficial)

WebDriverExpectedCondition
in package

Canned ExpectedConditions which are generally useful within webdriver tests.

Tags
see
WebDriverWait

Table of Contents

Properties

$apply  : callable
A callable function to be executed by WebDriverWait. It should return a truthy value, mostly boolean or a WebDriverElement, on success.

Methods

alertIsPresent()  : static
An expectation for whether an alert() box is present.
elementSelectionStateToBe()  : static
An expectation for checking if the given element is selected.
elementTextContains()  : static
An expectation for checking if the given text is present in the specified element.
elementTextIs()  : static
An expectation for checking if the given text exactly equals the text in specified element.
elementTextMatches()  : static
An expectation for checking if the given regular expression matches the text in specified element.
elementToBeClickable()  : static
An expectation for checking an element is visible and enabled such that you can click it.
elementToBeSelected()  : static
An expectation for checking if the given element is selected.
elementValueContains()  : static
An expectation for checking if the given text is present in the specified elements value attribute.
frameToBeAvailableAndSwitchToIt()  : static
Expectation for checking if iFrame exists. If iFrame exists switches driver's focus to the iFrame.
getApply()  : callable
invisibilityOfElementLocated()  : static
An expectation for checking that an element is either invisible or not present on the DOM.
invisibilityOfElementWithText()  : static
An expectation for checking that an element with text is either invisible or not present on the DOM.
not()  : mixed
An expectation with the logical opposite condition of the given condition.
numberOfWindowsToBe()  : static
An expectation checking the number of opened windows.
presenceOfAllElementsLocatedBy()  : static
An expectation for checking that there is at least one element present on a web page.
presenceOfElementLocated()  : static
An expectation for checking that an element is present on the DOM of a page.
refreshed()  : static
Wrapper for a condition, which allows for elements to update by redrawing.
stalenessOf()  : static
Wait until an element is no longer attached to the DOM.
textToBePresentInElement()  : static
An expectation for checking if the given text is present in the specified element.
textToBePresentInElementValue()  : static
An expectation for checking if the given text is present in the specified elements value attribute.
titleContains()  : static
An expectation for checking substring of a page Title.
titleIs()  : static
An expectation for checking the title of a page.
titleMatches()  : static
An expectation for checking current page title matches the given regular expression.
urlContains()  : static
An expectation for checking substring of the URL of a page.
urlIs()  : static
An expectation for checking the URL of a page.
urlMatches()  : static
An expectation for checking current page URL matches the given regular expression.
visibilityOf()  : static
An expectation for checking that an element, known to be present on the DOM of a page, is visible.
visibilityOfAnyElementLocated()  : static
An expectation for checking than at least one element in an array of elements is present on the DOM of a page and visible.
visibilityOfElementLocated()  : static
An expectation for checking that an element is present on the DOM of a page and visible.
__construct()  : mixed

Properties

$apply

A callable function to be executed by WebDriverWait. It should return a truthy value, mostly boolean or a WebDriverElement, on success.

private callable $apply

Methods

alertIsPresent()

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

public static alertIsPresent() : static
Return values
static

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

elementSelectionStateToBe()

An expectation for checking if the given element is selected.

public static elementSelectionStateToBe(mixed $element_or_by, bool $selected) : static
Parameters
$element_or_by : mixed

Either the element or the locator.

$selected : bool

The required state.

Return values
static

Condition returns whether the element is selected.

elementTextContains()

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

public static elementTextContains(WebDriverBy $by, string $text) : static

To check exact text match use elementTextIs() condition.

Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The text to be presented in the element.

Return values
static

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

elementTextIs()

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

public static elementTextIs(WebDriverBy $by, string $text) : static

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

Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The expected text of the element.

Return values
static

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

elementTextMatches()

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

public static elementTextMatches(WebDriverBy $by, string $regexp) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

$regexp : string

The regular expression to test against.

Return values
static

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

elementToBeClickable()

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

public static elementToBeClickable(WebDriverBy $by) : static
Parameters
$by : WebDriverBy

The locator used to find the element

Return values
static

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

elementToBeSelected()

An expectation for checking if the given element is selected.

public static elementToBeSelected(mixed $element_or_by) : static
Parameters
$element_or_by : mixed

Either the element or the locator.

Return values
static

Condition returns whether the element is selected.

elementValueContains()

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

public static elementValueContains(WebDriverBy $by, string $text) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The text to be presented in the element value.

Return values
static

Condition returns whether the text is present in value attribute.

frameToBeAvailableAndSwitchToIt()

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

public static frameToBeAvailableAndSwitchToIt(string $frame_locator) : static
Parameters
$frame_locator : string

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

Return values
static

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

getApply()

public getApply() : callable
Return values
callable

A callable function to be executed by WebDriverWait

invisibilityOfElementLocated()

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

public static invisibilityOfElementLocated(WebDriverBy $by) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

Return values
static

Condition returns whether no visible element located.

invisibilityOfElementWithText()

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

public static invisibilityOfElementWithText(WebDriverBy $by, string $text) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The text of the element.

Return values
static

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

numberOfWindowsToBe()

An expectation checking the number of opened windows.

public static numberOfWindowsToBe(int $expectedNumberOfWindows) : static
Parameters
$expectedNumberOfWindows : int
Return values
static

presenceOfAllElementsLocatedBy()

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

public static presenceOfAllElementsLocatedBy(WebDriverBy $by) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

Return values
static

Condition return an array of WebDriverElement once they are located.

presenceOfElementLocated()

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

public static presenceOfElementLocated(WebDriverBy $by) : static

This does not necessarily mean that the element is visible.

Parameters
$by : WebDriverBy

The locator used to find the element.

Return values
static

Condition returns the WebDriverElement which is located.

refreshed()

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

public static refreshed(WebDriverExpectedCondition $condition) : static

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
$condition : WebDriverExpectedCondition

The condition wrapped.

Return values
static

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

stalenessOf()

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

public static stalenessOf(WebDriverElement $element) : static
Parameters
$element : WebDriverElement

The element to wait for.

Return values
static

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

textToBePresentInElement()

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

public static textToBePresentInElement(WebDriverBy $by, string $text) : static

To check exact text match use elementTextIs() condition.

Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The text to be presented in the element.

Tags
codeCoverageIgnore
deprecated

Use WebDriverExpectedCondition::elementTextContains() instead

Return values
static

Condition returns whether the text is present in the element.

textToBePresentInElementValue()

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

public static textToBePresentInElementValue(WebDriverBy $by, string $text) : static
Parameters
$by : WebDriverBy

The locator used to find the element.

$text : string

The text to be presented in the element value.

Tags
codeCoverageIgnore
deprecated

Use WebDriverExpectedCondition::elementValueContains() instead

Return values
static

Condition returns whether the text is present in value attribute.

titleContains()

An expectation for checking substring of a page Title.

public static titleContains(string $title) : static
Parameters
$title : string

The expected substring of Title.

Return values
static

Condition returns whether current page title contains given string.

titleIs()

An expectation for checking the title of a page.

public static titleIs(string $title) : static
Parameters
$title : string

The expected title, which must be an exact match.

Return values
static

Condition returns whether current page title equals given string.

titleMatches()

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

public static titleMatches(string $titleRegexp) : static
Parameters
$titleRegexp : string

The regular expression to test against.

Return values
static

Condition returns whether current page title matches the regular expression.

urlContains()

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

public static urlContains(string $url) : static
Parameters
$url : string

The expected substring of the URL

Return values
static

Condition returns whether current URL contains given string.

urlIs()

An expectation for checking the URL of a page.

public static urlIs(string $url) : static
Parameters
$url : string

The expected URL, which must be an exact match.

Return values
static

Condition returns whether current URL equals given one.

urlMatches()

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

public static urlMatches(string $urlRegexp) : static
Parameters
$urlRegexp : string

The regular expression to test against.

Return values
static

Condition returns whether current URL matches the regular expression.

visibilityOf()

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

public static visibilityOf(WebDriverElement $element) : static

Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

Parameters
$element : WebDriverElement

The element to be checked.

Return values
static

Condition returns the same WebDriverElement once it is visible.

visibilityOfAnyElementLocated()

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

public static visibilityOfAnyElementLocated(WebDriverBy $by) : static

Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

Parameters
$by : WebDriverBy

The located used to find the element.

Return values
static

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

visibilityOfElementLocated()

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

public static visibilityOfElementLocated(WebDriverBy $by) : static

Visibility means that the element is not only displayed but also has a height and width that is greater than 0.

Parameters
$by : WebDriverBy

The locator used to find the element.

Return values
static

Condition returns the WebDriverElement which is located and visible.


        
On this page

Search results