12
12
from selenium import webdriver
13
13
from selenium .common .exceptions import ElementClickInterceptedException
14
14
from selenium .common .exceptions import InvalidSessionIdException
15
+ from selenium .common .exceptions import SessionNotCreatedException
15
16
from selenium .webdriver .chrome .service import Service as ChromeService
16
17
from selenium .webdriver .common .options import ArgOptions
17
18
from selenium .webdriver .common .service import utils as service_utils
@@ -4277,11 +4278,11 @@ def get_local_driver(
4277
4278
driver .quit ()
4278
4279
except Exception :
4279
4280
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 )
4280
4285
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 )
4285
4286
driver = undetected .Chrome (
4286
4287
options = chrome_options ,
4287
4288
user_data_dir = user_data_dir ,
@@ -4298,6 +4299,19 @@ def get_local_driver(
4298
4299
mac_certificate_error = True
4299
4300
else :
4300
4301
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
4301
4315
if mac_certificate_error :
4302
4316
cf_lock_path = (
4303
4317
constants .MultiBrowser .CERT_FIXING_LOCK
0 commit comments