@@ -1511,7 +1511,11 @@ def get_local_driver(
1511
1511
options = firefox_options ,
1512
1512
)
1513
1513
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
+ ):
1515
1519
# Firefox probably just auto-updated itself.
1516
1520
# Trying again right after that often works.
1517
1521
return webdriver .Firefox (
@@ -1529,9 +1533,24 @@ def get_local_driver(
1529
1533
else :
1530
1534
if selenium4 :
1531
1535
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.
1535
1554
else :
1536
1555
return webdriver .Firefox (
1537
1556
service_log_path = os .path .devnull ,
0 commit comments