Waiting for Elements

Implicit Wait

There is an implicit search timeout that is applied to every time a web element is searched. This search timeout is defined in the settings file by using the search_timeout setting key.

It can also be set by using the set_search_timeout and get_search_timeout actions.

Note that this timeout only waits for the element to be present (to exist in the DOM). It does not wait for the element to be visible, clickable, enabled, etc.

Explicit Wait

There are a few ways to wait for an element to be present.

Using the wait_for_element_present action:

from golem import actions

actions.wait_for_element_present('#button-id', 15)
actions.click('#button-id')

Using the timeout argument in the find methods:

from golem import actions

button = actions.get_browser().find('#button-id', timeout=15)
button.click()

Using the wait_for_element_present method of the WebDriver class:

from golem import actions

actions.get_browser().wait_for_element_present('#button-id', timeout=15)

Wait for Element Displayed

Very often an element needs to be displayed (visible) besides being present. Here are the ways to wait for an element to be visible.

Using the wait_displayed setting. This is defined globally for every search.

Using the wait_for_element_displayed action.

Using the wait_displayed argument in the find methods:

from golem import actions

actions.get_browser().find('#button-id', 15, wait_displayed=True).click()

Using the wait_displayed method of the WebElement class:

from golem import actions

button = actions.get_browser().find('#button-id')
button.wait_displayed().click()