Improve error-handling for Firefox tests

This commit is contained in:
Michael Mintz 2022-07-14 00:18:28 -04:00
parent 5cd2e4ac0d
commit e6a5ec875e
1 changed files with 23 additions and 4 deletions

View File

@ -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(
@ -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,