Skip to content

Commit

Permalink
Improve error-handling for Firefox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Jul 14, 2022
1 parent 5cd2e4a commit e6a5ec8
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions seleniumbase/core/browser_launcher.py
Expand Up @@ -1511,7 +1511,11 @@ def get_local_driver(
options=firefox_options,
)
except Exception as e:
if "Process unexpectedly closed" in e.msg:
if (
"Process unexpectedly closed" in e.msg
or "Failed to read marionette port" in e.msg
or "A connection attempt failed" in e.msg
):
# Firefox probably just auto-updated itself.
# Trying again right after that often works.
return webdriver.Firefox(
Expand All @@ -1529,9 +1533,24 @@ def get_local_driver(
else:
if selenium4:
service = FirefoxService(log_path=os.path.devnull)
return webdriver.Firefox(
service=service, options=firefox_options
)
try:
return webdriver.Firefox(
service=service, options=firefox_options
)
except Exception as e:
if (
"Process unexpectedly closed" in e.msg
or "Failed to read marionette port" in e.msg
or "A connection attempt failed" in e.msg
):
# Firefox probably just auto-updated itself.
# Trying again right after that often works.
return webdriver.Firefox(
service=service,
options=firefox_options,
)
else:
raise Exception(e.msg) # Not an obvious fix.
else:
return webdriver.Firefox(
service_log_path=os.path.devnull,
Expand Down

0 comments on commit e6a5ec8

Please sign in to comment.