@@ -227,7 +227,7 @@ def _add_chrome_proxy_extension(
227227 chrome_options = add_chrome_ext_dir (chrome_options , PROXY_DIR_PATH )
228228
229229 else :
230- # Pytest multi-threaded test
230+ # Pytest multithreaded test
231231 if zip_it :
232232 proxy_zip_lock = fasteners .InterProcessLock (PROXY_ZIP_LOCK )
233233 with proxy_zip_lock :
@@ -2007,6 +2007,8 @@ def get_local_driver(
20072007 )
20082008 driver = Edge (service = service , options = edge_options )
20092009 except Exception as e :
2010+ if not hasattr (e , "msg" ):
2011+ raise
20102012 auto_upgrade_edgedriver = False
20112013 edge_version = None
20122014 if (
@@ -2063,6 +2065,8 @@ def get_local_driver(
20632065 capabilities = capabilities ,
20642066 )
20652067 except Exception as e :
2068+ if not hasattr (e , "msg" ):
2069+ raise
20662070 auto_upgrade_edgedriver = False
20672071 edge_version = None
20682072 if (
@@ -2114,7 +2118,7 @@ def get_local_driver(
21142118 arg_join = " " .join (sys .argv )
21152119 if ("-n" in sys .argv ) or (" -n=" in arg_join ) or (arg_join == "-c" ):
21162120 # Skip if multithreaded
2117- raise Exception ("Can't run Safari tests in multi-threaded mode!" )
2121+ raise Exception ("Can't run Safari tests in multithreaded mode!" )
21182122 warnings .simplefilter ("ignore" , category = DeprecationWarning )
21192123 return webdriver .safari .webdriver .WebDriver (quiet = False )
21202124 elif browser_name == constants .Browser .OPERA :
@@ -2343,21 +2347,36 @@ def get_local_driver(
23432347 or is_using_uc (undetectable , browser_name )
23442348 ):
23452349 if selenium4_or_newer :
2350+ if headless and "linux" not in PLATFORM :
2351+ undetectable = False # No support for headless
23462352 if undetectable :
23472353 from seleniumbase import undetected
23482354 from urllib .error import URLError
23492355
23502356 if "linux" in PLATFORM :
2351- chrome_options .headless = False # Use xvfb
2357+ chrome_options .headless = False # Use Xvfb
2358+ if "--headless" in (
2359+ chrome_options .arguments
2360+ ):
2361+ chrome_options .arguments .remove (
2362+ "--headless"
2363+ )
23522364 cert = "unable to get local issuer certificate"
2365+ uc_chrome_version = None
2366+ if (
2367+ use_version .isnumeric
2368+ and int (use_version ) >= 72
2369+ ):
2370+ uc_chrome_version = int (use_version )
23532371 uc_lock = fasteners .InterProcessLock (
23542372 constants .MultiBrowser .DRIVER_FIXING_LOCK
23552373 )
2356- with uc_lock :
2374+ with uc_lock : # No UC multithreaded tests
23572375 try :
23582376 driver = undetected .Chrome (
23592377 options = chrome_options ,
2360- headless = headless ,
2378+ headless = False , # Xvfb needed
2379+ version_main = uc_chrome_version ,
23612380 )
23622381 except URLError as e :
23632382 if (
@@ -2371,7 +2390,8 @@ def get_local_driver(
23712390 )
23722391 driver = undetected .Chrome (
23732392 options = chrome_options ,
2374- headless = headless ,
2393+ headless = False , # Xvfb needed
2394+ version_main = uc_chrome_version ,
23752395 )
23762396 else :
23772397 raise
@@ -2402,6 +2422,8 @@ def get_local_driver(
24022422 service_log_path = os .devnull ,
24032423 )
24042424 except Exception as e :
2425+ if not hasattr (e , "msg" ):
2426+ raise
24052427 auto_upgrade_chromedriver = False
24062428 if "This version of ChromeDriver only supports" in e .msg :
24072429 auto_upgrade_chromedriver = True
@@ -2513,6 +2535,8 @@ def get_local_driver(
25132535 try :
25142536 return webdriver .Chrome (options = chrome_options )
25152537 except Exception as e :
2538+ if not hasattr (e , "msg" ):
2539+ raise
25162540 auto_upgrade_chromedriver = False
25172541 if "This version of ChromeDriver only supports" in e .msg :
25182542 auto_upgrade_chromedriver = True
0 commit comments