I am trying to test the contrast of a website that has both a light and dark theme.
I want to test contrast in dark mode, but Chrome defaults to light mode.
When I go to chrome://flags
, I see the option:
Auto Dark Mode for Web Contents
Automatically render all web contents using a dark theme. – Mac, Windows, Linux, ChromeOS, Android, Fuchsia, Lacros
#enable-force-dark
How can I launch Chrome from the command line with this flag? (Or some other way to get Chrome to always open sites in dark mode in a CI environment, using testing tools like pa11y-ci and lighthouse-ci.)
Related question: How can I emulate prefers-color-scheme media query in Chrome? The answers to this question describe a way to solve this issue from within the Chrome UI, but I need to do it from the command line for a CI environment.
The command line flag for that feature is --enable-features=WebContentsForceDark
. You can see the command line arguments in about:version after you turned them on in about://flags.