python selenium webscraping "NoSuchElementException" not recognized python selenium webscraping "NoSuchElementException" not recognized selenium selenium

python selenium webscraping "NoSuchElementException" not recognized


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

If you would like to give details of the exception in your output then you can use:

except NoSuchElementException as exc:    print(exc) # and/or other actions to recover 


You sould use from selenium.common.exceptions import * and then write except NoSuchElementException