selenium.common.exceptions.NoSuchElementException
from selenium.common.exceptions import NoSuchElementException
try:
element = driver.find_element(By.CLASS_NAME, class_name)
print(element.text)
except NoSuchElementException:
print('Элемент не найден')