You can try to wait few seconds for required element to appear:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.zmrzlina-misa.cz")
time_to_wait = 5
try:
element = WebDriverWait(driver, time_to_wait).until(
EC.presence_of_element_located((By.XPATH, "//*[@data-optanongroupid]"))
)
print('Element with "data-optanongroupid" attribute found')
except:
print('No elements with "data-optanongroupid" attribute found')
If it found add your code to try
block, if not found – to except
block
CLICK HERE to find out more related problems solutions.