How to find dash elements while testing with selenium

I realized that dash elements layout are different from the traditional UI layout. I am trying to automate testing on a dropdown element which normally would be of type “slelect”. So the selenium syntax to click on the dropdown and select the value would be as follows

select = Select(driver.find_element(By.XPATH, '//*[@id="dropdown-0"]/div'))
#select by visible text
select.select_by_visible_text('Manufacturing')

This is the following error i get

The layout for the dropdown is as follows.

Any help would be appreciated!
@chriddyp

You should check out dash-testing, and you might find the integration tests for dcc.Dropdown helpful too.

1 Like

Thank you for directing me to that link. I might figure out what i need.

In my case, I am able to find the element by ID ‘dropdown-0’ but am not able to interact with it. Any help with that? @tcbegley

I found a solution with the help of this repo from 2019:

to choose OPTION in DROPDOWN_NAME use this:

# open dropdown
dropdown = dash_duo.driver.find_element_by_css_selector("div#DROPDOWN_NAME")
dropdown.click()
# chose option
menu = dropdown.find_element_by_css_selector("div.Select-menu-outer")
options = menu.find_elements_by_css_selector("div.VirtualizedSelectOption")
for option in options:
    if option.text == 'OPTION':
        option.click()
1 Like