Skip to content

Commit e88e06d

Browse files
authored
Merge pull request #1414 from seleniumbase/handle-edge-cases
Handle edge cases with EdgeDriver and js_click()
2 parents e25573d + d547d1a commit e88e06d

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<meta property="og:title" content="SeleniumBase: Python Web Automation and E2E Testing" />
33
<meta property="og:description" content="Fast, easy, and reliable Web/UI testing with Python." />
44
<meta property="og:keywords" content="Python, pytest, selenium, webdriver, testing, automation, seleniumbase, framework, RPA, behave, BDD, nosetests, dashboard, recorder, reports, gui, screenshots">
5-
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" />
5+
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5b.png" />
66
<link rel="icon" href="https://seleniumbase.io/img/green_logo2.png" />
77

8-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_5b.png" alt="SeleniumBase" title="SeleniumBase" width="320" /></a></p>
8+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3c.png" alt="SeleniumBase" title="SeleniumBase" width="320" /></a></p>
99
<p align="center"><b>Powerful end-to-end testing with <a href="https://www.selenium.dev/documentation/">Selenium</a>, <a href="https://www.python.org/about/">Python</a>, and <a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a>.</b></p>
1010

1111
<p align="center"><a href="https://pypi.python.org/pypi/seleniumbase" target="_blank"><img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=3399EE" alt="PyPI version" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/releases" target="_blank"><img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=22AAEE" alt="GitHub version" /></a> <a href="https://seleniumbase.io"><img src="https://img.shields.io/badge/docs-seleniumbase.io-11BBAA.svg" alt="SeleniumBase Docs" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions" target="_blank"><img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase" target="_blank"><img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="SeleniumBase" /></a></p>

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "3.5.3"
2+
__version__ = "3.5.4"

seleniumbase/core/browser_launcher.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,14 @@ def get_local_driver(
18371837
edge_version = e.msg.split(
18381838
"only supports MSEdge version "
18391839
)[1].split(" ")[0]
1840+
elif "DevToolsActivePort file doesn't exist" in e.msg:
1841+
service = EdgeService(
1842+
executable_path=LOCAL_EDGEDRIVER,
1843+
log_path=os.path.devnull,
1844+
)
1845+
# https://stackoverflow.com/a/56638103/7058266
1846+
edge_options.add_argument("--remote-debugging-port=9222")
1847+
return Edge(service=service, options=edge_options)
18401848
if not auto_upgrade_edgedriver:
18411849
raise Exception(e.msg) # Not an obvious fix. Raise.
18421850
else:
@@ -1884,6 +1892,14 @@ def get_local_driver(
18841892
edge_version = e.msg.split(
18851893
"only supports MSEdge version "
18861894
)[1].split(" ")[0]
1895+
elif "DevToolsActivePort file doesn't exist" in e.msg:
1896+
service = EdgeService(
1897+
executable_path=LOCAL_EDGEDRIVER,
1898+
log_path=os.path.devnull,
1899+
)
1900+
# https://stackoverflow.com/a/56638103/7058266
1901+
edge_options.add_argument("--remote-debugging-port=9222")
1902+
return Edge(service=service, options=edge_options)
18871903
if not auto_upgrade_edgedriver:
18881904
raise Exception(e.msg) # Not an obvious fix. Raise.
18891905
else:

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)