Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesSet Playwright’s colorScheme to 'dark' before the page renders, then capture it with page.screenshot(). Use fullPage: true for the whole scrollable document. For a repeatable visual-regression check, use Playwright Test’s toHaveScreenshot() instead of saving a one-off image.
How Playwright dark-mode screenshots work
Dark mode is not a special screenshot format or a screenshot-only option. Playwright emulates the browser’s prefers-color-scheme media feature, which websites can use to select their dark theme. Set the preference before navigation when possible so the site sees it as the page loads. Playwright’s API reference documents colorScheme values of 'light' and 'dark'; null disables the emulation.
The setting controls the preference exposed to the page. It does not guarantee that every site will look dark: a page may not offer a dark theme, may require a separate in-page theme switch, or may apply theme styles only after its own scripts run. If the site has a theme control, automate that control as part of the scenario too.
Capture a dark-mode screenshot with JavaScript
This standalone Playwright script creates a browser context in dark mode, opens a page, saves a full-page PNG, and closes the browser. It uses the playwright package rather than the Playwright Test runner.
Recommended Free Tools
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
import { chromium } from 'playwright';
const browser = await chromium.launch();
try {
const context = await browser.newContext({ colorScheme: 'dark' });
const page = await context.newPage();
await page.goto('https://example.com');
await page.screenshot({ path: 'dark-mode.png', fullPage: true });
await context.close();
} finally {
await browser.close();
}
Save the file as an ES module, for example dark-shot.mjs, and run it in an environment where Playwright and its browser are installed. Replace the example URL with the page you need to capture. The output path is relative to the process’s working directory unless you provide an absolute path.
Use an existing page
If the page has already been created, change its emulated media preference with page.emulateMedia(). Do this before navigating for the most consistent initial render:
await page.emulateMedia({ colorScheme: 'dark' });
await page.goto('https://example.com');
await page.screenshot({ path: 'dark-mode.png' });
This runtime method is useful when a test intentionally changes from light to dark during one scenario. If you only need a dark screenshot, configuring the context or test from the start makes the intended mode clearer and avoids capturing an earlier light-state render.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Choose where to set the color scheme
Use the narrowest setting that matches the scope of the test. A suite default keeps all relevant tests consistent; a single-test setting avoids changing unrelated tests; context creation is convenient for scripts; runtime emulation is suited to a deliberate mid-scenario switch.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Set a project-wide default
In a Playwright Test configuration file, set the use option. Tests using that configuration will start with the dark color scheme:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
colorScheme: 'dark',
},
});
Set one test to dark mode
For a single test file or group, use test.use(). The setting applies to the tests in its scope:
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
import { test } from '@playwright/test';
test.use({ colorScheme: 'dark' });
test('dark-mode screenshot', async ({ page }) => {
await page.goto('https://example.com');
await page.screenshot({ path: 'dark-mode.png' });
});
If only one test in a file needs dark mode, scope the setting accordingly rather than making it the default for every test in the file. This makes the test’s assumptions easier to see when someone later adds light-mode coverage.
Set the preference on a manually created context
When using the browser API directly, supply colorScheme when creating the context, as in the standalone example. Pages created from that context inherit its emulated preference. This is a useful boundary when a script needs separate light and dark captures: create one context per mode and keep each capture’s settings explicit.
Choose what to capture
The color-scheme setting and the screenshot scope are independent decisions. Playwright can save the visible viewport, the full scrollable document, a single element, or an in-memory image buffer for later processing.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
- Viewport:
await page.screenshot({ path: 'dark-viewport.png' })captures the current page view. - Full page:
await page.screenshot({ path: 'dark-full.png', fullPage: true })captures the full scrollable page rather than only the current viewport. - One element:
await page.locator('.header').screenshot({ path: 'dark-header.png' })captures the matched element. Replace.headerwith a selector for the component you want. - Buffer:
const image = await page.screenshot()returns image bytes instead of requiring a path, which is useful when another step will process or compare the image.
For a long page, make sure the content you expect is present before capture. Full-page mode extends the capture to the scrollable document; it does not make a site’s missing or not-yet-rendered content appear. An element capture is often a better choice for a component-level check because it avoids unrelated page regions.
Compare dark-mode screenshots in Playwright Test
For visual regression, use Playwright Test’s toHaveScreenshot() assertion. On the first run, it creates a reference image; later runs compare against that reference. PNG is the default snapshot format. A snapshot name ending in .webp selects WebP.
import { test, expect } from '@playwright/test';
test.use({ colorScheme: 'dark' });
test('dark theme matches its baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('dark-homepage.png');
});
Use a named snapshot that makes its mode and scope apparent, especially when the same page also has a light-mode baseline. Treat a newly generated reference as a proposed baseline to inspect, not as proof that the page is correct: an accidental layout or theme change can be recorded just as readily as an intended one.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Keep baseline and comparison environments consistent
Playwright cautions that rendering can differ with the host operating system, browser version, settings, hardware, power source, and headless mode. Generate and review baselines in the same environment used for comparisons. If the environment changes, a difference image may reflect the rendering setup rather than a website regression.
For more stable results, keep the browser and execution environment consistent across baseline generation and test runs. Also make the intended color scheme explicit in the test rather than relying on a machine’s default preference. When diagnosing a mismatch, first check that the page loaded the same state and that the test is using the expected browser and environment before changing the baseline.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. Its screenshot API can return an image or PDF from a GET request; the following cURL example saves a WebP capture. See the ScreenshotNeo documentation for request options, including dark mode, and for language-specific usage.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo’s capture workflow accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Troubleshooting dark-mode captures
- The screenshot is still light: Confirm that
colorScheme: 'dark'is set on the context or test that created the page, or callpage.emulateMedia({ colorScheme: 'dark' })before the capture. The emulation sets the browser preference; it cannot force a site that does not implement a dark theme to change its design. - The page starts light and changes after loading: Apply the preference before navigation, then capture after the site has reached the state you intend to test. If the application has its own theme selector, interact with it as part of the test rather than assuming the media preference replaces that control.
- The full-page image is incomplete: Check whether the page’s content is present before capturing and whether the desired target is actually part of the scrollable document. If the problem is limited to one region, capture that element directly with a locator screenshot.
- The visual assertion fails on a different machine: Compare the browser and host environment used for the baseline with the one running the test. Operating system, browser version, settings, hardware, power source, and headless mode can change rendering; review environment consistency before accepting a new baseline.
- A screenshot file is not where expected: Check the output path relative to the process’s working directory, or use an absolute path. If the next step needs to inspect image bytes rather than a saved file, omit
pathand use the buffer returned bypage.screenshot().
Performance, reliability, and cost considerations
A screenshot’s main practical cost is the browser work needed to load and render the page, so avoid launching a separate browser for every image when a script can reuse its browser and create the contexts it needs. Close contexts and browsers when finished, as in the example, to release resources reliably. If your workflow captures many pages, consider whether they need full-page images: larger captures produce more image data to store, transfer, or compare than a viewport or focused element.
For regression tests, the most important reliability trade-off is environmental consistency. A baseline is meaningful only in relation to the rendering conditions under which it was created. Keep capture mode, browser setup, and comparison environment intentional, and review updates when those conditions change. Playwright’s cited documentation supplies API behavior rather than a published performance benchmark, so there is no general capture-time figure to apply to every site or test environment.
Playwright’s screenshot APIs do not introduce a per-image service charge in the workflow shown here; operational costs depend on the machines and infrastructure used to run the browser and retain artifacts. A hosted screenshot service has its own plan and billing model, so check that service’s current terms and request documentation when choosing between local browser automation and an API.
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.




