Skip to content

Commit 9e53a48

Browse files
committed
Firefox: Retry if "Process unexpectedly closed"
1 parent b8f66d7 commit 9e53a48

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,10 +1431,21 @@ def get_local_driver(
14311431
if selenium4:
14321432
service = FirefoxService(
14331433
executable_path=LOCAL_GECKODRIVER)
1434-
return webdriver.Firefox(
1435-
service=service,
1436-
options=firefox_options,
1437-
)
1434+
try:
1435+
return webdriver.Firefox(
1436+
service=service,
1437+
options=firefox_options,
1438+
)
1439+
except Exception as e:
1440+
if "Process unexpectedly closed" in e.msg:
1441+
# Firefox probably just auto-updated itself.
1442+
# Trying again right after that often works.
1443+
return webdriver.Firefox(
1444+
service=service,
1445+
options=firefox_options,
1446+
)
1447+
else:
1448+
raise Exception(e.msg) # Not an obvious fix.
14381449
else:
14391450
return webdriver.Firefox(
14401451
executable_path=LOCAL_GECKODRIVER,

0 commit comments

Comments
 (0)