Skip to content

Commit

Permalink
Merge pull request #859 from plotly/add-dropdown-select-#858
Browse files Browse the repository at this point in the history
add api for dropdown
  • Loading branch information
byronz authored Aug 9, 2019
2 parents 7880d5b + 5b04fb7 commit d5ff7fc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions dash/testing/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,34 @@ def wait_for_page(self, url=None, timeout=10):
)
)

def select_dcc_dropdown(self, selector, value=None, index=None):
dropdown = self.driver.find_element_by_css_selector(selector)
dropdown.click()

menu = dropdown.find_element_by_css_selector("div.Select-menu-outer")
logger.debug(
"the available options are %s", "|".join(menu.text.split("\n"))
)

options = menu.find_elements_by_css_selector(
"div.VirtualizedSelectOption"
)
if options:
if isinstance(index, int):
options[index].click()
return

for option in options:
if option.text == value:
option.click()
return

logger.error(
"cannot find matching option using value=%s or index=%s",
value,
index,
)

def toggle_window(self):
"""switch between the current working window and the new opened one"""
idx = (self._window_idx + 1) % 2
Expand Down

0 comments on commit d5ff7fc

Please sign in to comment.