Raise TimeoutException when wait_for_element() fails

master
Dan Howe 6 years ago
parent 7e2449b717
commit 72d38d31a2

@ -40,11 +40,19 @@ def has_admin():
def wait_for_element(driver, by, x, timeout=60): def wait_for_element(driver, by, x, timeout=60):
try: """Wait for element on page to load.
Args:
driver: selenium webdriver object
by: locator strategy (e.g. By.ID)
x: locator string
timeout: maximum wait time (seconds)
Raises
TimeoutException if element does not load within timeout period
"""
element_present = EC.presence_of_element_located((by, x)) element_present = EC.presence_of_element_located((by, x))
WebDriverWait(driver, timeout).until(element_present) WebDriverWait(driver, timeout).until(element_present)
except TimeoutException:
print("Timed out waiting for page to load")
def get_telemetered_bore(driver, bore_id, start_date, end_date): def get_telemetered_bore(driver, bore_id, start_date, end_date):

Loading…
Cancel
Save