Sometimes on a page I\'ll be looking for an element which may or may not be there. I wanted to try/catch this case with a NoSuchElementException
, which selenium
You sould use from selenium.common.exceptions import *
and then write except NoSuchElementException
You need to import the exception first
from selenium.common.exceptions import NoSuchElementException
and then you can reference it
except NoSuchElementException:
# handle the element not existing