Merge pull request #14937 from mvdbeek/fix_selenium_select2_selection

Fix select2 value selection in selenium
This commit is contained in:
Martin Cech
2022-11-07 19:39:50 +01:00
committed by GitHub
+9 -1
View File
@@ -1934,7 +1934,15 @@ class NavigatesGalaxy(HasDriver):
# Wait for select2 options to load and then click to add this one.
self.send_enter(text_element)
else:
select_elem = drop_elem.find_elements(By.CSS_SELECTOR, ".select2-result-label")[0]
candidate_elements = drop_elem.find_elements(By.CSS_SELECTOR, ".select2-result-label")
# try to find exact match
for elem in candidate_elements:
if elem.text == value:
select_elem = elem
break
else:
# Pick first match. We're replacing select2 anyway ...
select_elem = elem
action_chains = self.action_chains()
action_chains.move_to_element(select_elem).click().perform()
self.wait_for_selector_absent_or_hidden("#select2-drop")