(Python)I am trying to catch an exception while using Selenium chrome Driver, however, I have so far been unable to catch the exception and prompt the "Failed at this click!" print statement. Any advice on how to go about this issue (The original issue is with the .click() as I am having trouble with consistency but I think catching the exception at this point would be enough to get by).
Exception below :
File "/Users/J*****i/anaconda/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: unknown error: Element is not clickable at point (145, 1818)
(Session info: chrome=64.0.3282.186)
(Driver info: chromedriver=2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.10.5 x86_64)
Code below :
URL2 = URL_in_2
driver = webdriver.Chrome('/Users/J******i/Desktop/chromedriver')
driver.get(URL2)
cookie_disclaimer = driver.find_element_by_xpath("//*[contains(text(), 'OK')]")
cookie_disclaimer.click()
try:
element = WebDriverWait(driver,10).until(
EC.presence_of_element_located((By.ID, "sub-navigation"))
)
except:
"Failed at this click!"
finally:
print("[D2] successful first click: " + str(element) + " found")