From c757d579ce4af1d3b7270b67e28fc66ee41fabb9 Mon Sep 17 00:00:00 2001 From: Michael Oliver Date: Fri, 25 Aug 2023 09:26:55 -0700 Subject: [PATCH] don't remove user_data_dir if it contains the substring headless should be able to use paths that contain the substring headless. For example users/{username}/{headless,gui} --- undetected_chromedriver/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/undetected_chromedriver/__init__.py b/undetected_chromedriver/__init__.py index d31055a..b4fed04 100644 --- a/undetected_chromedriver/__init__.py +++ b/undetected_chromedriver/__init__.py @@ -301,8 +301,9 @@ class Chrome(selenium.webdriver.chrome.webdriver.WebDriver): for arg in options.arguments: if any([_ in arg for _ in ("--headless", "headless")]): - options.arguments.remove(arg) - options.headless = True + if not arg.startswith("--user-data-dir="): + options.arguments.remove(arg) + options.headless = True if "lang" in arg: m = re.search("(?:--)?lang(?:[ =])?(.*)", arg)