Skip to content

Commit e6a5ec8

Browse files
committed
Improve error-handling for Firefox tests
1 parent 5cd2e4a commit e6a5ec8

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,7 +1511,11 @@ def get_local_driver(
15111511
options=firefox_options,
15121512
)
15131513
except Exception as e:
1514-
if "Process unexpectedly closed" in e.msg:
1514+
if (
1515+
"Process unexpectedly closed" in e.msg
1516+
or "Failed to read marionette port" in e.msg
1517+
or "A connection attempt failed" in e.msg
1518+
):
15151519
# Firefox probably just auto-updated itself.
15161520
# Trying again right after that often works.
15171521
return webdriver.Firefox(
@@ -1529,9 +1533,24 @@ def get_local_driver(
15291533
else:
15301534
if selenium4:
15311535
service = FirefoxService(log_path=os.path.devnull)
1532-
return webdriver.Firefox(
1533-
service=service, options=firefox_options
1534-
)
1536+
try:
1537+
return webdriver.Firefox(
1538+
service=service, options=firefox_options
1539+
)
1540+
except Exception as e:
1541+
if (
1542+
"Process unexpectedly closed" in e.msg
1543+
or "Failed to read marionette port" in e.msg
1544+
or "A connection attempt failed" in e.msg
1545+
):
1546+
# Firefox probably just auto-updated itself.
1547+
# Trying again right after that often works.
1548+
return webdriver.Firefox(
1549+
service=service,
1550+
options=firefox_options,
1551+
)
1552+
else:
1553+
raise Exception(e.msg) # Not an obvious fix.
15351554
else:
15361555
return webdriver.Firefox(
15371556
service_log_path=os.path.devnull,

0 commit comments

Comments
 (0)