Skip to content

browser.wait.until.text#

Functions#

changes(xpath, baseline_text, timeout=None) #

Wait until the text of an element changes compared to a baseline text, e.g. after a form action.

Parameters:

Name Type Description Default
xpath str

XPath of the text element.

required
baseline_text str

Baseline text to compare the new text against. It's evaluated as any change.

required
timeout float | None

In seconds. Timeout to wait for text in element to change. If None, the global timeout setting is used (default 5 seconds).

None
Example
1
2
3
4
5
6
7
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    baseline_text = browser.get.text("//h1")
    browser.click.button("//xpath/to/button")
    browser.wait.until.text.changes("//h1", baseline_text)

contains(xpath, regex, timeout=None) #

Wait until the text of an element contains a specified text fragment, e.g. after a form action.

Parameters:

Name Type Description Default
xpath str

XPath of the text element.

required
regex str

The comparison can contain both a text fragment or a regular expression. Case insensitive.

required
timeout float | None

In seconds. Timeout to wait for text in element to contain the fragment. If None, the global timeout setting is used (default 5 seconds).

None
Example
1
2
3
4
5
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.wait.until.text.contains("//h1", "Example")

equals(xpath, regex, timeout=None) #

Wait until the text of an element has changed to a specific text, e.g. after a form action.

Parameters:

Name Type Description Default
xpath str

XPath of the text element.

required
regex str

Regular expression to compare the text element against. Case sensitive and is evaluated as an exact match.

required
timeout float | None

In seconds. Timeout to wait for text jn element to match the condition. If None, the global timeout setting is used (default 5 seconds).

None
Example
1
2
3
4
5
from browserist import Browser

with Browser() as browser:
    browser.open.url("https://example.com")
    browser.wait.until.text.equals("//h1", "Example Domain")