After updating google chrome this weekend, headless mode using Selenium python API is bringing up a blank window when running in windows. The identical code I had running on a Debian VM does not work any longer.
Here is a code snippet:
chrome_options = Options()
chrome_options.add_argument("--headless=new") #previously used --headless
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--disable-automation")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
driver = webdriver.Chrome(options=chrome_options)
To isolate the problem, I removed all fqdn dns blocks I had enforced for privacy including: ad.doubleclick.net, analytics.yahoo.com, google-analytics.com, googleadservices.com, plausible.io, stats.g.doubleclick.net
It's a new bug in Chrome / Chromedriver 129 when using the new headless mode on Windows:
https://github.com/SeleniumHQ/selenium/issues/14514#issuecomment-2357777800.
https://issues.chromium.org/issues/359921643#comment2
In the meantime, use --window-position=-2400,-2400
to hide the window.
chrome_options.add_argument("--window-position=-2400,-2400")
Or use Chrome's older headless mode (while it still exists), until the fix is released:
chrome_options.add_argument("--headless=old")