From c7addc1cf9c1b198e84d2c3df64480bf7e618217 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Sun, 17 Jul 2022 08:03:24 -0400 Subject: [PATCH] Fix intermittent Firefox issue --- seleniumbase/core/browser_launcher.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index c9a5479d..34189e69 100755 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -2,6 +2,7 @@ import logging import os import re import sys +import time import urllib3 import warnings from selenium import webdriver @@ -1518,17 +1519,21 @@ def get_local_driver( ) except BaseException as e: if ( - "Process unexpectedly closed" in str(e) + "geckodriver unexpectedly exited" in str(e) + or "Process unexpectedly closed" in str(e) or "Failed to read marionette port" in str(e) or "A connection attempt failed" in str(e) or hasattr(e, "msg") and ( - "Process unexpectedly closed" in e.msg + "geckodriver unexpectedly exited" in e.msg + or "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. + # Firefox probably just auto-updated itself, + # which causes intermittent issues to occur. # Trying again right after that often works. + time.sleep(0.1) return webdriver.Firefox( service=service, options=firefox_options, @@ -1550,17 +1555,21 @@ def get_local_driver( ) except BaseException as e: if ( - "Process unexpectedly closed" in str(e) + "geckodriver unexpectedly exited" in str(e) + or "Process unexpectedly closed" in str(e) or "Failed to read marionette port" in str(e) or "A connection attempt failed" in str(e) or hasattr(e, "msg") and ( - "Process unexpectedly closed" in e.msg + "geckodriver unexpectedly exited" in e.msg + or "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. + # Firefox probably just auto-updated itself, + # which causes intermittent issues to occur. # Trying again right after that often works. + time.sleep(0.1) return webdriver.Firefox( service=service, options=firefox_options,