Selenium has its own exception-handling package:
from selenium.common.exceptions import StaleElementReferenceException try: #your code except StaleElementReferenceException: #exception