Unable to catch Selenium NoSuchElementException

Maybe I am missing something very basic here, but my "except" block doesn't catch the exception it's intended for when using selenium. For example:

from selenium.common.exceptions import NoSuchElementException

try:
   driver.find_element_by_xpath(*some_path*)
except NoSuchElementException:
   pass

This still breaks with a NoSuchElementException if the element isn't there. How is this possible?



Read more here: https://stackoverflow.com/questions/68482053/unable-to-catch-selenium-nosuchelementexception

Content Attribution

This content was originally published by Overflow_101 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: