Skip to content

Commit 3a46d83

Browse files
committed
Update Firefox error-handling
1 parent f75cda6 commit 3a46d83

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,18 +1509,23 @@ def get_local_driver(
15091509
if selenium4:
15101510
service = FirefoxService(
15111511
executable_path=LOCAL_GECKODRIVER,
1512-
log_path=os.path.devnull,
1512+
log_path=os.devnull,
15131513
)
15141514
try:
15151515
return webdriver.Firefox(
15161516
service=service,
15171517
options=firefox_options,
15181518
)
1519-
except Exception as e:
1519+
except BaseException as e:
15201520
if (
1521-
"Process unexpectedly closed" in e.msg
1522-
or "Failed to read marionette port" in e.msg
1523-
or "A connection attempt failed" in e.msg
1521+
"Process unexpectedly closed" in str(e)
1522+
or "Failed to read marionette port" in str(e)
1523+
or "A connection attempt failed" in str(e)
1524+
or hasattr(e, "msg") and (
1525+
"Process unexpectedly closed" in e.msg
1526+
or "Failed to read marionette port" in e.msg
1527+
or "A connection attempt failed" in e.msg
1528+
)
15241529
):
15251530
# Firefox probably just auto-updated itself.
15261531
# Trying again right after that often works.
@@ -1529,25 +1534,30 @@ def get_local_driver(
15291534
options=firefox_options,
15301535
)
15311536
else:
1532-
raise Exception(e.msg) # Not an obvious fix.
1537+
raise # Not an obvious fix.
15331538
else:
15341539
return webdriver.Firefox(
15351540
executable_path=LOCAL_GECKODRIVER,
1536-
service_log_path=os.path.devnull,
1541+
service_log_path=os.devnull,
15371542
options=firefox_options,
15381543
)
15391544
else:
15401545
if selenium4:
1541-
service = FirefoxService(log_path=os.path.devnull)
1546+
service = FirefoxService(log_path=os.devnull)
15421547
try:
15431548
return webdriver.Firefox(
15441549
service=service, options=firefox_options
15451550
)
1546-
except Exception as e:
1551+
except BaseException as e:
15471552
if (
1548-
"Process unexpectedly closed" in e.msg
1549-
or "Failed to read marionette port" in e.msg
1550-
or "A connection attempt failed" in e.msg
1553+
"Process unexpectedly closed" in str(e)
1554+
or "Failed to read marionette port" in str(e)
1555+
or "A connection attempt failed" in str(e)
1556+
or hasattr(e, "msg") and (
1557+
"Process unexpectedly closed" in e.msg
1558+
or "Failed to read marionette port" in e.msg
1559+
or "A connection attempt failed" in e.msg
1560+
)
15511561
):
15521562
# Firefox probably just auto-updated itself.
15531563
# Trying again right after that often works.

0 commit comments

Comments
 (0)