selenium exception handling python
from selenium.common.exceptions import NoSuchElementException try: driver.find_element_by_xpath("//span") except NoSuchElementException:
Here is what the above code is Doing:
1. It’s trying to find an element with the xpath “//span”.
2. If it can’t find the element, it will raise a NoSuchElementException.
3. If it can find the element, it will do nothing.