Currently writing up a Python Selenium script with Headless Chrome. Here are the options I'm using to build the driver:
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--single-process")
chrome_options.add_argument("--user-data-dir=C:\\Users\\Me\\AppData\\Local\\Google\\Chrome\\User Data")
chrome_options.add_argument('--profile-directory=Profile 1')
chrome_options.add_argument('--log-level=3')
chrome_options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome(options=chrome_options)
driver.get(...)
I have two profiles, Default and Profile 1. Default is my personal profile and I want my script to run within Profile 1.
Profile 1 is a pure clean slate, no extensions, and is logged into one random website I'm using to check which profile is used.
I run the script with all instances of Chrome closed.
With the above args, the script will use Default (bad). However, if I comment out the --headless arg line, the script will run within Profle 1, unheadless.
I have juggled args around, also threw in --no-sandbox --disable-dev-shm-usage --remote-debugging-port for good measure, to no avail.
I didn't find any open issues within the Selenium project regarding this.
I am using the up to date chromedriver 111.0.5563.64 on Chrome 111.0.5563.111.
Sadly this similar question does not contain a solution.