webdriver_test_tools.webdriver.locate module

Utility functions for locating elements

webdriver_test_tools.webdriver.locate.by_element_text(element_text, element_type='*', exact_match=False)[source]

Returns a locator that selects an element with the specified text

  • element_text – The text of the element to locate.

  • element_type – (Optional) The tag type of the element. If unspecified, will search all tag types for the specified text.

  • exact_match – (Default = False) If True, will only match elements with the exact string as its text. If False, match elements whose text contains the specified string but may also contain other text.


Locator selecting elements by the specified text


Return a locator that selects input, select, textarea, and (optionally) button elements

To narrow down results, this is best used on the conainer element where the desired inputs are located. E.g.:

form_element = driver.find_element_by_id('form-id')
input_elements = form_element.find_elements(*locate.input_elements())

exclude_buttons – (Default = False) If set to True, omit button elements from selector


Locator selecting input elements