try: self.driver.find_element(*LogInLocators.submit_btn).send_keys(Keys.ENTER) except StaleElementReferenceException as msg: print("unable to locate element submit_btn%s", msg) print("relocate element submit_btn") self.driver.find_element(*LogInLocators.submit_btn).send_keys(Keys.ENTER)