[Python] Extract element from a dropdown list

Discussão em 'Python' iniciado por Stack, Julho 11, 2025.

  1. Stack

    Stack Membro Participativo

    Good evening from Austria!

    I have tried to access an element from a dropdown list, but without any success. The element where the dropdown list is stored is: . Once the button to the dropdown has been clicked, aria_controls = "mui-76755" appears with the corresponding element "mui-76755-option-0" (depending on the rank in the dropdown). I unfortunately havent figured out how to select the first element using Selenium in Python. For further info: https://directory.brcgs.com/ --> click on country --> select country.

    Please help me solve this!

    Code so far:

    I attached my code below to show you what I have done so far.

    url = 'https://directory.brcgs.com/'
    driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
    driver.get(url)
    driver.maximize_window()
    time.sleep(5)
    #driver.find_element(By.XPATH,'/html/body/div[3]/div[1]/div/div[2]/div[2]/div[1]/div[2]').click()
    time.sleep(5)
    driver.find_element(By.CSS_SELECTOR, "#root > div.page-container > div > div.PublicDirectory_publicDirectory__3yPKO > div.PublicDirectory_main__109y3 > div.FilterGroup_FilterGroup__1tA0A.PublicDirectory_filters__Rg1EU > div:nth-child(2)").click()
    time.sleep(15)

    input_element = driver.find_element(By.CSS_SELECTOR, "#root > div.page-container > div > div.PublicDirectory_publicDirectory__3yPKO > div.PublicDirectory_main__109y3 > div.FilterGroup_FilterGroup__1tA0A.PublicDirectory_filters__Rg1EU > div.MuiPaper-root.MuiAccordion-root.filter-row.Mui-expanded.MuiAccordion-rounded.MuiPaper-elevation1.MuiPaper-rounded > div.MuiCollapse-container.MuiCollapse-entered > div > div > div > div > div > div > div")
    input_element.click()
    time.sleep(15)

    Continue reading...

Compartilhe esta Página