finding this particular data in a website using selenium or python

You can try to wait few seconds for required element to appear:

from selenium import webdriver
from import By
from import WebDriverWait
from import expected_conditions as EC

driver = webdriver.Chrome()

time_to_wait = 5

    element = WebDriverWait(driver, time_to_wait).until(
        EC.presence_of_element_located((By.XPATH, "//*[@data-optanongroupid]"))
    print('Element with "data-optanongroupid" attribute found')
    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.

Leave a Comment

Your email address will not be published.

Scroll to Top