1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python seleniumBase xpath [closed]

Discussão em 'Python' iniciado por Stack, Abril 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to parse an html page with python and seleniumBase. As we all know, we have to imitate human behaviour. I have a dropdown built using Button and Div. I am able to click on the button but selecting an item from the div is difficult. The Xoath would not resolve to anything. DevToll on chrome is able to solve the xpath.

    Please refer to the image. I have indicated my starting point with an arrow.

    [​IMG]

    This is my python code:

    This my python code

    dropdownDiv = WebDriverWait(driver, 20).until(
    EC.element_to_be_clickable((By.XPATH,"//div[contains(@class,'css-1615w3r') and contains(@class,'eu4oa1w0')]/div)")) # Replace with actual button text or locator
    )
    print(dropdownDiv.size)
    print(dropdownDiv.get_attribute('class'))
    print(dropdownDiv.get_attribute('style'))
    print(dropdownDiv.get_attribute('id'))
    print("number of children +{len(dropdownDiv)}")
    country_span = WebDriverWait(driver, 15).until(
    EC.element_to_be_clickable(dropdownDiv.find_element(By.XPATH, ".//ul"))
    )


    It is not able to see the div inside the div marked in red on the image.

    I get this error:

    sleeping for 35 seconds
    hello
    Traceback (most recent call last):
    File "C:\Users\xxxxxx\PycharmProjects\PythonProject\webScrapper.py", line 134, in <module>
    dropdownDiv = WebDriverWait(driver, 50).until(
    EC.element_to_be_clickable((By.XPATH,"//div[@class='css-1615w3r eu4oa1w0']/div")) # Replace with actual button text or locator
    )
    File "C:\Users\Nesan\PycharmProjects\PythonProject\.venv\Lib\site-packages\selenium\webdriver\support\wait.py", line 146, in until
    raise TimeoutException(message, screen, stacktrace)
    selenium.common.exceptions.TimeoutException: Message:

    Process finished with exit code 1

    Continue reading...

Compartilhe esta Página