python sleenium no such element exception code example
Example 1: python exception element not found
from selenium.common.exceptions import NoSuchElementException
try:
if driver.find_element_by_class_name(test_element_class_name).is_displayed():
print('found')
except NoSuchElementException:
pass
Example 2: selenium how to handle element not found python
try:
elem = driver.find_element_by_xpath(".//*[@id='SORM_TB_ACTION0']")
elem.click()
except nosuchelementexception:
pass