To capture a website’s own dark theme, set Chrome’s emulated prefers-color-scheme media feature to dark before navigating, then wait for the page to render and take the Selenium screenshot. This asks the site to respond to a dark-mode preference; it does not force a dark theme onto a site that has not implemented one.
Emulate the site’s dark-mode preference with Chrome DevTools Protocol
Chrome’s DevTools Protocol (CDP) command for this is Emulation.setEmulatedMedia. Its payload sets the prefers-color-scheme feature to dark:
As an Amazon Associate I earn from qualifying purchases.
{
"features": [
{ "name": "prefers-color-scheme", "value": "dark" }
]
}
With Selenium’s Python Chrome driver, execute_cdp_cmd sends that command. Apply it before navigation so the preference is in place when the page starts rendering:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
url = "https://example.com"
options = webdriver.ChromeOptions()
# Add any required Chrome options here, such as headless mode.
driver = webdriver.Chrome(options=options)
try:
driver.execute_cdp_cmd(
"Emulation.setEmulatedMedia",
{
"features": [
{"name": "prefers-color-scheme", "value": "dark"}
]
},
)
driver.get(url)
# Replace this with a condition that means the page is ready for your test.
WebDriverWait(driver, 20).until(
lambda browser: browser.execute_script(
"return document.readyState"
) == "complete"
)
driver.save_screenshot("dark-mode.png")
finally:
driver.quit()
The wait above checks document loading, not that a particular application has finished changing themes. For a page that renders its theme asynchronously, wait for a page-specific signal—such as a theme attribute or a visible element in the expected state—before saving the screenshot.
#1 Best Overall
- 14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
Adapt the command to your Selenium language binding
The CDP command and payload are the protocol-level part; how Selenium sends them depends on the language binding and its version. Python Chrome drivers commonly expose execute_cdp_cmd. Java uses Selenium’s DevTools integration, and other bindings have their own APIs. Check the documentation for your installed Selenium binding and Chrome version rather than assuming one invocation works across languages.
Make sure you are testing the dark mode you intend
Emulating prefers-color-scheme: dark tests whether the site responds to the user’s dark color-scheme preference, using its CSS or JavaScript. The browser cannot make a site implement a site-authored dark theme. A site may instead rely on a theme toggle, a saved preference, or server-side selection, so inspect the application’s behavior if the screenshot remains light.
Rank #2
- 256 GB SSD of storage.
- Multitasking is easy with 16GB of RAM
- Equipped with a blazing fast Core i5 2.00 GHz processor.
| Test mode | What it tests | Use it for |
|---|---|---|
Emulated prefers-color-scheme: dark |
The site’s response to a dark color-scheme preference. | Checking the site’s own dark CSS or JavaScript. |
| Chrome automatic dark mode | Chrome’s generated dark rendering of web content. | Inspecting browser-generated dark treatment, including on a site without its own dark theme. |
| DevTools Rendering panel | Interactive, manual emulation in the current tab. | Diagnosing the visual state before automating it. |
Chrome’s Rendering panel provides a manual prefers-color-scheme: dark option; refresh the page to inspect its response. The panel’s separate automatic dark mode tests Chrome-generated rendering instead. While automatic dark mode is enabled, Chrome disables the separate prefers-color-scheme selector and sets it to dark automatically.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesUse a repeatable capture sequence
- Create the Chrome WebDriver session. Set the browser options and viewport required by the test.
- Apply the CDP emulation. Send
Emulation.setEmulatedMediawithprefers-color-schemeset todark. - Navigate to the target URL. Applying the setting first lets the page see the preference during its initial rendering.
- Wait for the expected page state. Use an application-specific condition if client-side code, fonts, images, or other asynchronous work can affect the screenshot.
- Capture the screenshot. Call Selenium’s screenshot method after the relevant content is ready.
- Reset before testing another mode. If you will use the same session for light-mode tests, clear or change the emulation override, or start a fresh session. The override can affect later pages in that session; confirm reset behavior against the Chrome and protocol versions you use.
Troubleshoot screenshots that do not look dark
- The screenshot is still light: check whether the site responds to
prefers-color-scheme, whether the command was sent to the active Chrome target, and whether an application toggle or saved preference takes precedence. - The page changes after capture: wait for the page’s actual theme and content to finish rendering. A document-ready check alone may not cover asynchronous application work.
- The CDP command fails: confirm the installed Selenium binding supports a CDP command path and that its supported protocol version matches the Chrome/ChromeDriver setup. The command interface is version-sensitive.
- You want Chrome to darken a page automatically: use Chrome’s automatic dark mode for that test. It is a different test from checking the site’s own response to the emulated preference.
Or skip the browser setup
ScreenshotNeo is a screenshot API and MCP server. For dark-mode captures, use its dark-mode option; see the ScreenshotNeo documentation for the current request parameters. The following is the supplied one-call cURL example; replace the target URL as needed:
Rank #3
- WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
- 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
- 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
- CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
- LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




