I'm trying to launch Google Chrome with dark mode enabled using Selenium WebDriver in Python, but I'm having trouble getting the add_argument method to work. Here's the code I'm using:
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import Chrome
import time
chrome_options = Options()
chrome_options.add_argument('--force-dark-mode')
driver = Chrome(options=chrome_options)
time.sleep(5)
driver.quit()
When I run this code, it launches Google Chrome, but dark mode is not enabled. I've also tried using the --force-dark-mode-on but they didn't work either.
I'm using Google Chrome version 78, which should support the --force-dark-mode option. I'm not seeing any error messages or warnings in the console or logs.
What could be causing add_argument not to work for enabling dark mode in Google Chrome with Selenium WebDriver? Are there any other options or workarounds that I can try?