[Python] Selenium webdriver can't locate class

Discussão em 'Python' iniciado por Stack, Outubro 2, 2024.

  1. Stack

    Stack Membro Participativo

    I need to retrieve the sub elements from the class of this element:

    <td data-automation-id="horse-racing-section-row-1-meeting-cell" class="meetingCellDesktopMediumAbove_femjjxq">

    The sub elements:

    <a href="/horse-racing/australia-nz/ballarat"><div class="meetingCellInternalContainerAbove_fyg3mg0"><div class="leftCellContainer_frjo067"><span class="size14_f7opyze medium_f1wf24vo meetingName_f1jzu4qi" data-automation-id="horse-racing-section-row-1-meeting-name">Ballarat</span>

    I have used all these methods to try locate it:

    races = driver.find_elements(By.XPATH, "//td[@class, 'meetingCellDesktopMediumAbove_femjjxq']")

    races = driver.find_elements(By.XPATH, "//td[contains(@class, 'meetingCellDesktopMediumAbove_femjjxq')]")

    races = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//td[contains(@class, 'meetingCellDesktopMediumAbove_femjjxq')]")))

    races = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//td[contains(@class, 'meetingCellDesktopMediumAbove_femjjxq')]")))

    races = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//td[@class, 'meetingCellDesktopMediumAbove_femjjxq']")))

    races = driver.execute_script('return document.querySelectorAll("td.meetingCellDesktopMediumAbove_femjjxq")')

    races = driver.find_elements(By.CSS_SELECTOR, 'meetingCellDesktopMediumAbove_femjjxq')

    races = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, 'td.meetingCellDesktopMediumAbove_femjjxq')))

    When I try:

    for race in races:
    print(race.text)


    It returns nothing.

    Continue reading...

Compartilhe esta Página