Skip to content

Commit 6279e89

Browse files
committed
Perform optimizations on "select_option_by_*()" methods
1 parent 70ff467 commit 6279e89

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,6 +2356,12 @@ def __select_option(
23562356
element = self.wait_for_element_present(
23572357
dropdown_selector, by=dropdown_by, timeout=timeout
23582358
)
2359+
try:
2360+
element = self.wait_for_element_clickable(
2361+
dropdown_selector, by=dropdown_by, timeout=1.2
2362+
)
2363+
except Exception:
2364+
self.wait_for_ready_state_complete()
23592365
if self.is_element_visible(dropdown_selector, by=dropdown_by):
23602366
self.__demo_mode_highlight_if_active(
23612367
dropdown_selector, dropdown_by
@@ -2369,18 +2375,28 @@ def __select_option(
23692375
Select(element).select_by_value(option)
23702376
else:
23712377
Select(element).select_by_visible_text(option)
2372-
except (StaleElementReferenceException, ENI_Exception):
2378+
time.sleep(0.05)
2379+
self.wait_for_ready_state_complete()
2380+
except Exception:
2381+
time.sleep(0.25)
23732382
self.wait_for_ready_state_complete()
2374-
time.sleep(0.14)
23752383
element = self.wait_for_element_present(
23762384
dropdown_selector, by=dropdown_by, timeout=timeout
23772385
)
2386+
try:
2387+
element = self.wait_for_element_clickable(
2388+
dropdown_selector, by=dropdown_by, timeout=1.2
2389+
)
2390+
except Exception:
2391+
self.wait_for_ready_state_complete()
23782392
if option_by == "index":
23792393
Select(element).select_by_index(option)
23802394
elif option_by == "value":
23812395
Select(element).select_by_value(option)
23822396
else:
23832397
Select(element).select_by_visible_text(option)
2398+
time.sleep(0.05)
2399+
self.wait_for_ready_state_complete()
23842400
latest_window_count = len(self.driver.window_handles)
23852401
if (
23862402
latest_window_count > pre_window_count

0 commit comments

Comments
 (0)