Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use Playwright headless for unattended tests and CI; use headed when you need to watch the browser or debug interactively. Headless is Playwright Test’s default. Switch with --headed or headless: false; use --debug for the Inspector. In CI, headed runs need a display such as Xvfb.

The short answer

Playwright’s normal workflow is headless: the browser runs without opening a window, and test results, traces, screenshots and videos are collected by the runner. That makes headless the practical choice for continuous integration, scheduled checks and local runs where nobody needs to watch the page.

Choose headed when a person needs to see the page, inspect a locator, demonstrate a flow or diagnose a rendering problem interactively. Playwright Test enables it with npx playwright test --headed; the browser API uses headless: false. The --debug command combines a visible browser with the Playwright Inspector.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Headless and headed compared

Consideration Headless Headed
Window No visible browser window; observe through terminal output and artifacts. A browser window is visible while actions run.
Best fit Automated local runs, CI, scheduled jobs and parallel workers. Interactive debugging, demonstrations and diagnosing visual or interaction behavior.
Configuration Default; omit the option or set headless: true. Set headless: false or pass --headed.
Display requirement No visible display is required in the normal workflow. Needs a desktop display locally; CI commonly supplies Xvfb.
Chromium implementation Uses a separate Chromium headless shell by default when no channel is selected. Uses Playwright’s regular Chromium build.
Diagnostics Use traces, screenshots, video, logs or UI Mode. Watch the browser, use Inspector, and optionally slow actions with slowMo.

How to run each mode

Default headless test run

From a project that has Playwright Test installed, run:

npx playwright test

No browser window opens. The runner reports results in the terminal and can retain configured artifacts.

Visible test run

npx playwright test --headed

This changes the test-runner launch to a visible browser. It is useful when you want to watch navigation, clicks, dialogs or layout changes.

Interactive debugging

npx playwright test --debug

Debug mode opens the Playwright Inspector and runs browsers headed. The Inspector lets you step through actions, edit and test locators live, pick locators from the page and inspect actionability logs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Launching a browser from JavaScript

import { chromium } from 'playwright';

// Headless is the default.
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
await browser.close();

// Explicit headed launch for local debugging.
const debugBrowser = await chromium.launch({
  headless: false,
  slowMo: 100
});
const debugPage = await debugBrowser.newPage();
await debugPage.goto('https://example.com');
await debugPage.pause();
await debugBrowser.close();

The slowMo: 100 value delays operations by 100 milliseconds; it is an illustrative debugging setting, not a performance measurement. Remove it for normal execution.

Use the Inspector instead of guessing

A headed window answers “what is on screen?” while the Inspector answers “why did Playwright refuse this action?” Start with --debug, pause near the failing step, and check the locator and actionability log. Locator picking is particularly useful when a selector matches the wrong element or when an overlay intercepts a click.

For failures that only occur in an unattended run, first reproduce them with --debug. Then run headless with a trace, screenshot or video enabled in your project configuration so the same evidence is available in CI. A visible window is a diagnostic aid, not a substitute for durable artifacts.

Headed runs in CI: provide a display

Most CI workers do not have a desktop display. A headed launch therefore fails unless the job provides one. Playwright’s documented pattern is to run the test command under Xvfb:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
xvfb-run npx playwright test --headed

Install Xvfb and the browser’s required system dependencies in the CI image first. If the job does not need visual observation, keep it headless and avoid the virtual-display setup. When headed execution is required—for example, to investigate a rendering issue—retain the display setup only for that diagnostic job.

Why Chromium can look different between modes

When no browser channel is specified, Playwright ships a regular Chromium build for headed operation and a separate Chromium headless shell for headless operation. This implementation difference can matter for high-fidelity visual checks or browser features that depend on the full Chrome UI stack.

Selecting the chromium channel opts into Chromium’s newer headless mode. Playwright describes that mode as closer to regular Chrome and more feature-complete for high-accuracy testing. If a test behaves differently only in headless mode, compare the default headless shell with the chromium channel before changing application code.

Do not choose on an assumed speed number

There is no universal Playwright benchmark that quantifies a fixed speed or memory advantage for headless over headed execution. Browser version, page complexity, video, tracing, network conditions, workers and the CI machine all affect the result.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a meaningful decision, measure your own workload:

  • Run the same test set with identical workers, retries, tracing and video settings.
  • Record wall-clock duration, peak memory and failure rate on the same machine type.
  • Compare cold-browser startup separately from repeated page actions.
  • Keep the mode that meets your reliability target; use headed only where its visibility provides value.

Choose a mode by task

Continuous integration and scheduled monitoring

Use headless. It does not require a visible display and works naturally with containers and ephemeral workers. Save traces, screenshots or videos on failure so a developer can investigate without rerunning the job locally.

Writing or repairing a test

Start with npx playwright test --debug. The visible browser, Inspector, locator picker and actionability logs shorten the feedback loop. Once the locator and sequence are stable, run the test headless in the same way your CI job will.

Demonstrations and training

Use headed mode so observers can follow navigation and interactions. Add a modest slowMo only when the audience needs time to see each action; do not commit that delay to production test runs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Visual or rendering investigations

Reproduce in headed mode first, then verify the result in the exact headless configuration used by CI. If the difference persists, test the chromium channel and compare screenshots at the same viewport, device scale factor and browser version.

Remote Linux jobs

Prefer headless unless the investigation specifically needs a window. For headed execution, use Xvfb and ensure the image contains all display and browser dependencies. A virtual display makes a window available to the process; it does not make the job interactive for a person unless you also expose that session.

Configuration patterns that avoid surprises

Make the mode explicit when it matters

import { chromium } from 'playwright';

const isDebug = process.env.PWDEBUG === '1';
const browser = await chromium.launch({
  headless: !isDebug,
  slowMo: isDebug ? 100 : 0
});

This keeps unattended runs headless while allowing a deliberate local opt-in. Do not infer headed mode from whether a developer happens to have a desktop session; make the choice part of the command or environment.

Keep browser context settings identical

Viewport, locale, timezone, permissions, user agent, storage state and device scale factor can change what you see far more than the window itself. When comparing modes, hold those context settings constant and vary only headless.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use artifacts for headless diagnosis

A trace records the action timeline and DOM snapshots; screenshots show the rendered state; video shows the sequence. Configure the artifacts your team can retain and inspect, then open the Inspector only when an interactive reproduction is faster than artifact review.

Troubleshooting headless and headed runs

“No DISPLAY environment variable” or the browser exits immediately

Cause: A headed browser was launched on a machine without a display.

Fix: Run the job headless, or install and invoke Xvfb, for example xvfb-run npx playwright test --headed. Verify that the CI image includes the required display and browser libraries.

The window opens, but the test is too fast to observe

Cause: Headed mode changes visibility, not timing.

Fix: Use --debug, set a temporary slowMo value, or pause at a step with page.pause(). Remove those aids after diagnosing the issue.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A locator works headed but fails headless

Cause: Timing, viewport, font availability, animation, an overlay or a genuine rendering difference may be involved.

Fix: Capture a trace and screenshot in headless mode, inspect actionability logs, wait for a meaningful UI state rather than an arbitrary timeout, and compare viewport and browser-channel settings. Do not “fix” the test by adding random delays until you know which condition differs.

Headless screenshots differ from headed screenshots

Cause: The default headless shell and regular Chromium are separate builds, and display-related rendering inputs may differ.

Fix: Pin the same Playwright and browser versions, use identical context settings, and test the chromium channel’s newer headless mode when high visual fidelity is required.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Debug mode does not open the Inspector

Cause: The command may not be running through Playwright Test, the project may be using a conflicting debug environment variable, or the process may terminate before a pause.

Fix: Run npx playwright test --debug from the project directory, confirm the test is discovered, and add page.pause() after navigation if you need a deterministic stop.

The headed CI job hangs

Cause: A virtual display may be unavailable, the browser may be waiting on a dialog, or the test may depend on a screen size different from the local desktop.

Fix: Check Xvfb startup and logs, set a known viewport, capture a trace on timeout and close pages and contexts in fixtures. If no human inspection is needed, return the job to headless mode.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a reliable page image rather than an end-to-end browser test, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners like a visitor, then removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

See the complete parameter reference in the ScreenshotNeo documentation.

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));

ScreenshotNeo also offers an MCP server for AI clients such as Claude, Cursor and other MCP-compatible tools, with take_screenshot, get_page_info and capture_pdf. Its options cover full-page captures with lazy images, CSS-selector element captures, dark mode, 12 device presets or custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, pre-capture clicks, selector hiding, waits, ad/tracker/request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API and an OpenAPI specification. Existing parameter names used by other screenshot APIs also work.

The Free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 screenshots; yearly billing provides two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to start with the 1,000 monthly screenshots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can I switch modes for only one test?

Yes. Keep the project’s normal headless configuration and invoke that test or project with --headed, or launch a separate browser with headless: false in a small debugging script.

Does headed mode make a test more accurate?

Not automatically. It uses the regular Chromium build and provides visual access, but accuracy still depends on browser version, context settings, waits and test isolation.

Is ScreenshotNeo a replacement for Playwright end-to-end testing?

No. It is a screenshot and page-information service. Use Playwright when you need assertions and user-flow automation; use ScreenshotNeo when you need a cleaned, billed-only page capture or an MCP-accessible screenshot workflow.

Frequently Asked Questions

Can I switch modes for only one test?

Yes. Keep the project’s normal headless configuration and invoke that test or project with --headed, or launch a separate browser with headless: false in a small debugging script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does headed mode make a test more accurate?

Not automatically. It uses the regular Chromium build and provides visual access, but accuracy still depends on browser version, context settings, waits and test isolation.

Is ScreenshotNeo a replacement for Playwright end-to-end testing?

No. It is a screenshot and page-information service. Use Playwright when you need assertions and user-flow automation; use ScreenshotNeo when you need a cleaned, billed-only page capture or an MCP-accessible screenshot workflow.

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.