Skip to content

Commit ee5510a

Browse files
committed
UC-Headless Mode: Try Xvfb on Linux; otherwise skip UC
1 parent ed48c43 commit ee5510a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,21 +2347,36 @@ def get_local_driver(
23472347
or is_using_uc(undetectable, browser_name)
23482348
):
23492349
if selenium4_or_newer:
2350+
if headless and "linux" not in PLATFORM:
2351+
undetectable = False # No support for headless
23502352
if undetectable:
23512353
from seleniumbase import undetected
23522354
from urllib.error import URLError
23532355

23542356
if "linux" in PLATFORM:
2355-
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+
)
23562364
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)
23572371
uc_lock = fasteners.InterProcessLock(
23582372
constants.MultiBrowser.DRIVER_FIXING_LOCK
23592373
)
2360-
with uc_lock:
2374+
with uc_lock: # No UC multithreaded tests
23612375
try:
23622376
driver = undetected.Chrome(
23632377
options=chrome_options,
2364-
headless=headless,
2378+
headless=False, # Xvfb needed
2379+
version_main=uc_chrome_version,
23652380
)
23662381
except URLError as e:
23672382
if (
@@ -2375,7 +2390,8 @@ def get_local_driver(
23752390
)
23762391
driver = undetected.Chrome(
23772392
options=chrome_options,
2378-
headless=headless,
2393+
headless=False, # Xvfb needed
2394+
version_main=uc_chrome_version,
23792395
)
23802396
else:
23812397
raise

0 commit comments

Comments
 (0)