Skip to content

Commit a08216b

Browse files
committed
Refactoring
1 parent e654af0 commit a08216b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def click(
407407
except Stale_Exception:
408408
self.wait_for_ready_state_complete()
409409
time.sleep(0.16)
410-
element = page_actions.wait_for_element_visible(
410+
element = page_actions.wait_for_element_clickable(
411411
self.driver,
412412
selector,
413413
by,
@@ -444,6 +444,22 @@ def click(
444444
timeout=timeout,
445445
original_selector=original_selector,
446446
)
447+
if not page_actions.is_element_clickable(
448+
self.driver, selector, by
449+
):
450+
try:
451+
self.wait_for_element_clickable(
452+
selector, by, timeout=1.8
453+
)
454+
except Exception:
455+
pass # Find out which element would get the click instead
456+
element = page_actions.wait_for_element_visible(
457+
self.driver,
458+
selector,
459+
by,
460+
timeout=timeout,
461+
original_selector=original_selector,
462+
)
447463
href = None
448464
new_tab = False
449465
onclick = None
@@ -500,7 +516,7 @@ def click(
500516
self.__jquery_click(selector, by=by)
501517
except Exception:
502518
# One more attempt to click on the element
503-
element = page_actions.wait_for_element_visible(
519+
element = page_actions.wait_for_element_clickable(
504520
self.driver,
505521
selector,
506522
by,
@@ -2748,7 +2764,7 @@ def __select_option(
27482764
)
27492765
try:
27502766
element = self.wait_for_element_clickable(
2751-
dropdown_selector, by=dropdown_by, timeout=1.2
2767+
dropdown_selector, by=dropdown_by, timeout=1.8
27522768
)
27532769
except Exception:
27542770
self.wait_for_ready_state_complete()
@@ -2775,7 +2791,7 @@ def __select_option(
27752791
)
27762792
try:
27772793
element = self.wait_for_element_clickable(
2778-
dropdown_selector, by=dropdown_by, timeout=1.2
2794+
dropdown_selector, by=dropdown_by, timeout=1.8
27792795
)
27802796
except Exception:
27812797
self.wait_for_ready_state_complete()
@@ -12121,7 +12137,7 @@ def __js_click(self, selector, by="css selector"):
1212112137
):
1212212138
try:
1212312139
self.wait_for_element_clickable(
12124-
selector, by, timeout=1.2
12140+
selector, by, timeout=1.8
1212512141
)
1212612142
except Exception:
1212712143
pass

0 commit comments

Comments
 (0)