Answer the question
In order to leave comments, you need to log in
How to catch Selenium webdriver TimeoutException?
def get_clickable_element(driver, locator_strategy, locator, inactivity_sign, delay=60, logging=True):
try:
wait_for_page_inactivity(driver, inactivity_sign)
WebDriverWait(driver, delay).until(EC.element_to_be_clickable((locator_strategy, locator)))
element = driver.find_element(locator_strategy, locator)
return element
except TimeoutException as err:
if logging:
print("Элемент c " + locator + " не стал активен в течение " + str(delay) + " сек.")
print(err)
raise
File "myPath", line 39, in get_clickable_element
WebDriverWait(driver, delay).until(EC.element_to_be_clickable((locator_strategy, locator)))
File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Answer the question
In order to leave comments, you need to log in
from selenium.common.exceptions import TimeoutException
...
except TimeoutException:
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question