Skip to content

Commit 6acf508

Browse files
committed
Handle edge cases with js_click()
1 parent 3ae728f commit 6acf508

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11599,9 +11599,22 @@ def __js_click(self, selector, by="css selector"):
1159911599
)
1160011600
try:
1160111601
self.execute_script(script)
11602-
except Exception:
11603-
# If the regular mouse-simulated click fails, do a basic JS click
11602+
except Exception as e:
1160411603
self.wait_for_ready_state_complete()
11604+
if "Cannot read properties of null" in e.msg:
11605+
page_actions.wait_for_element_present(
11606+
self.driver, selector, by, timeout=3
11607+
)
11608+
if not page_actions.is_element_clickable(
11609+
self.driver, selector, by
11610+
):
11611+
try:
11612+
self.wait_for_element_clickable(
11613+
selector, by, timeout=1.2
11614+
)
11615+
except Exception:
11616+
pass
11617+
# If the regular mouse-simulated click fails, do a basic JS click
1160511618
script = (
1160611619
"""document.querySelector('%s').click();"""
1160711620
% css_selector

0 commit comments

Comments
 (0)