1212from selenium import webdriver
1313from selenium .common .exceptions import ElementClickInterceptedException
1414from selenium .common .exceptions import InvalidSessionIdException
15+ from selenium .common .exceptions import SessionNotCreatedException
1516from selenium .webdriver .chrome .service import Service as ChromeService
1617from selenium .webdriver .common .options import ArgOptions
1718from selenium .webdriver .common .service import utils as service_utils
@@ -4277,11 +4278,11 @@ def get_local_driver(
42774278 driver .quit ()
42784279 except Exception :
42794280 pass
4281+ uc_path = None
4282+ if os .path .exists (LOCAL_UC_DRIVER ):
4283+ uc_path = LOCAL_UC_DRIVER
4284+ uc_path = os .path .realpath (uc_path )
42804285 try :
4281- uc_path = None
4282- if os .path .exists (LOCAL_UC_DRIVER ):
4283- uc_path = LOCAL_UC_DRIVER
4284- uc_path = os .path .realpath (uc_path )
42854286 driver = undetected .Chrome (
42864287 options = chrome_options ,
42874288 user_data_dir = user_data_dir ,
@@ -4298,6 +4299,19 @@ def get_local_driver(
42984299 mac_certificate_error = True
42994300 else :
43004301 raise
4302+ except SessionNotCreatedException :
4303+ time .sleep (0.2 )
4304+ driver = undetected .Chrome (
4305+ options = chrome_options ,
4306+ user_data_dir = user_data_dir ,
4307+ driver_executable_path = uc_path ,
4308+ browser_executable_path = b_path ,
4309+ enable_cdp_events = cdp_events ,
4310+ headless = False , # Xvfb needed!
4311+ version_main = uc_chrome_version ,
4312+ use_subprocess = True , # Always!
4313+ )
4314+ uc_activated = True
43014315 if mac_certificate_error :
43024316 cf_lock_path = (
43034317 constants .MultiBrowser .CERT_FIXING_LOCK
0 commit comments