ui.utils

Utilities functions for API tests.

integrade.tests.ui.utils.elem_parent(elem)

Return the parent of a given element.

integrade.tests.ui.utils.element_has_text(element, text, timeout=5)

Wait for text in element, irrespective of markup, or timeout.

integrade.tests.ui.utils.fill_input_by_label(driver, element, label, value, timeout=None)

Click on a field label and enter text to the associated input.

integrade.tests.ui.utils.fill_input_by_placeholder(driver, element, label, value)

Click on a field label and enter text to the associated input.

integrade.tests.ui.utils.find_element_by_text(driver, text, *args, **kwargs)

Find an element which contains the given text.

If multiple results are found, return them ordered counting from the most specific to least.

“Specific” is defined by the length and depth of the matched element. The shorter the overall text of the element and the greater depth in the DOM the more specific it is considered. (length is only applicable when exact=False, otherwise only depth defines the specificity)

parameters: - driver Selenium or Element instance to locate under - text Text to search for on the page - fail_hard=False If True, raise exception on failure to locate - exact=True Only locate elements that exactly match the text. If

False, locate elements which contain the text somewhere in their content. (See n parameter description for the affects on specificity)
  • timeout=0.1 Time to spend re-checking for text to appear on page.
    Larger values behave as a “wait for…” search for the text.
integrade.tests.ui.utils.find_elements_by_text(driver, text, n=0, exact=True, selector='*', timeout=None)

Find an element which contains the given text.

integrade.tests.ui.utils.get_el_text(e)

Get the inner text of a WebElement and cache for quicker re-lookup.

integrade.tests.ui.utils.get_element_depth(element)

Determine the depth of the element in the page, counting from body.

Used to find the most specific element out of a set of matching elements for a condition where an element and its ancestors might match.

integrade.tests.ui.utils.page_has_text(driver, text, timeout=5)

Wait for text to be seen in page, irrespective of markup, or timeout.

integrade.tests.ui.utils.read_input_by_label(driver, element, label)

Click on a field label and read text from the associated input.

integrade.tests.ui.utils.retry_w_timeout(t, func=None, *args, **kwargs)

Retry a function until it returns truthy or a timeout occures.

class integrade.tests.ui.utils.return_url(browser)

Conext manager to control return back to a URL after steps completed.

class integrade.tests.ui.utils.wait_for_input_value(locator, value)

Selenium Wait helper to wait until an input has a specific value.

class integrade.tests.ui.utils.wait_for_page_text(value)

Selenium Wait helper to wait until specific text appears.

class integrade.tests.ui.utils.wait_for_result(timeout, func, *args, **kwargs)

Selenium Wait helper to wait until specific text appears.