Skip to content

browser.combo#

Functions#

search(term, settings, timeout=None) #

Standardised combination of methods to perform search.

Parameters:

Name Type Description Default
term str

Terms to search for.

required
settings SearchSettings

Add settings class.

required
timeout float | None

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

None
Example
from browserist import Browser, SearchSettings

search_settings = SearchSettings(
    url="https://google.com",
    input_xpath="//xpath/to/input_field",
    button_xpath="//xpath/to/search_button")

with Browser() as browser:
    browser.combo.search("some search term", search_settings)
    assert browser.tool.count_elements("//xpath/to/search_result_elements") > 0

Configuration Classes#

SearchSettings#

Object with data needed to make a search.

Parameters:

Name Type Description Default
url str | None

URL for the search page. Sometimes not needed if, for example, the search input field is available on all pages.

None
input_xpath str

XPath for the search input field.

required
button_xpath str

XPath for the search button.

required
await_search_results_url_contains str | None

Optionally wait for the search results page URL to change.

None
await_search_results_xpath str | None

Optionally wait for a search result element to be ready.

None