ScreenshotNeo

BlogComparisons

Chrome Headless vs Playwright for Website Screenshots in India

Compare Chrome Headless and Playwright for website screenshots, with runnable examples, setup guidance, troubleshooting, and an India-focused workflow recommendation.

By the ScreenshotNeo team4 October 202610 min read

Short answer: Use Chrome Headless for a one-off screenshot of a URL at a known viewport. Use Playwright when capture is part of a repeatable script, test, multi-step flow, cross-browser check, or visual regression suite. For a team in India, the location alone does not make either tool faster or more accurate: choose based on the browser and execution environment you need to represent.

These are different kinds of tools. Chrome Headless runs Chrome without a visible browser window. Playwright is an automation and testing library that can drive Chromium, Firefox, WebKit, and supported branded Chrome or Edge channels. Playwright can launch Chromium, so the comparison is often between a direct Chrome command and a browser automation layer. Chrome Headless documentation and Playwright browser documentation describe those roles and options.

Choose by workflow

Requirement Good starting choice Reason
One URL, one viewport, one image from a shell or script Chrome Headless Its command line has direct screenshot and window-size options.
Navigate through interactions or capture several states Playwright It exposes page navigation, selectors, and screenshot APIs in code.
Compare captures against committed reference images Playwright Test Its screenshot assertion can create and compare visual snapshots.
Check Chromium, Firefox, and WebKit behavior Playwright Projects can be configured for supported browser engines.
Represent branded Chrome Chrome Headless or Playwright with the chrome channel Playwright’s bundled Chromium and branded Chrome are distinct choices.

This is a workflow recommendation based on the documented capabilities, not a claim that one option is faster or produces better images. The official documentation reviewed does not establish an India-specific performance, reliability, cost, or browser-market winner.

Chrome Headless: capture a page from the command line

Install Chrome on the machine or CI runner where the capture will run. Then use --headless, --screenshot, and a viewport size. Chrome’s command-line reference documents --screenshot and recommends pairing it with --window-size. Add a bounded timeout for pages that need time to load. See the Chrome Headless command-line reference.

google-chrome --headless --no-sandbox --disable-gpu \
  --window-size=1440,1000 \
  --timeout=10000 \
  --screenshot=page.png \
  https://example.com

On systems where the Chrome executable is named chrome or chromium, replace google-chrome with that executable. The --no-sandbox flag is commonly needed in some container configurations; use your platform’s recommended sandbox setup where possible. A screenshot is written to the current directory.

Controlling capture timing

--timeout bounds the wait before capture. It does not guarantee that every client-rendered section, lazy image, or network-dependent widget has finished. If a page has animations or timer-driven content, Chrome also documents --virtual-time-budget for controlling virtual time. Verify the result against the target page’s actual loading behavior.

google-chrome --headless --no-sandbox \
  --window-size=1440,1000 \
  --virtual-time-budget=5000 \
  --screenshot=page.png \
  https://example.com

Chrome’s current Headless mode runs without visible UI and shares Chrome’s code. Since Chrome 132.0.6793.0, the old Headless implementation is distributed separately as chrome-headless-shell; see the Chrome Headless mode documentation. If a long-standing script depends on a particular binary or rendering behavior, identify and pin the binary rather than assuming every headless executable is identical.

Playwright: capture with JavaScript

Playwright is useful when the screenshot needs to be repeatable and controlled in code. Install the package and its browser binaries, save the following as capture.mjs, then run it with Node.js. The script accepts a URL and output path, sets a viewport, waits for the page’s load event, captures the page, and closes the browser even if capture fails.

npm init -y
npm install playwright
npx playwright install chromium
// capture.mjs
import { chromium } from 'playwright';

const url = process.argv[2] ?? 'https://example.com';
const output = process.argv[3] ?? 'page.png';
const browser = await chromium.launch({ headless: true });

try {
  const page = await browser.newPage({
    viewport: { width: 1440, height: 1000 },
    deviceScaleFactor: 1,
  });
  await page.goto(url, { waitUntil: 'load', timeout: 30_000 });
  await page.screenshot({ path: output, fullPage: true });
} finally {
  await browser.close();
}
node capture.mjs https://example.com page.png

Playwright’s library example documents launching a browser, opening a page, navigating, taking a screenshot, and closing the browser. See the Playwright library documentation.

Wait for the state you mean to capture

waitUntil: 'load' waits for the page load event, but applications can continue rendering afterward. Prefer waiting for a page-specific selector when the screenshot depends on a known element. Use networkidle only when that represents the desired ready state; analytics, polling, and persistent connections can prevent network quiet. A fixed delay may work for a known animation, but it is less robust than waiting for a meaningful page condition.

await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30_000 });
await page.locator('main article').waitFor({ state: 'visible', timeout: 15_000 });
await page.screenshot({ path: 'article.png', fullPage: true });

Choose full-page or viewport capture explicitly

Playwright’s fullPage: true captures the full scrollable page. Omit it for a viewport screenshot. Full-page images can become very tall, consume more memory, and include sections that load only after scrolling; test pages with lazy-loaded images if completeness matters.

Use branded Chrome when that is the target

Playwright can use its bundled Chromium or supported branded Chrome and Edge channels. For branded Chrome, configure channel: 'chrome' when launching Chromium:

const browser = await chromium.launch({
  channel: 'chrome',
  headless: true,
});

Use the bundled browser for a version-coupled automation environment; use a branded channel when the behavior being checked specifically needs that browser. Playwright notes that enterprise browser policies can affect branded-browser automation. Its browser binaries are coupled to Playwright releases, so rerun browser installation after upgrading Playwright. The browser setup guide covers channels, headless modes, and installation options.

Visual regression with Playwright Test

If the goal is to catch visual changes rather than simply save an image, use Playwright Test’s screenshot assertion. A minimal test can establish a reference on its first run and compare subsequent runs:

// tests/home.spec.js
import { test, expect } from '@playwright/test';

test('homepage matches its visual reference', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page).toHaveScreenshot('homepage.png', {
    fullPage: true,
  });
});
npm install --save-dev @playwright/test
npx playwright install chromium
npx playwright test

Review and commit reference images using your team’s normal code review process. Playwright’s visual comparisons guide explains screenshot assertions and cautions that operating system, browser version, settings, hardware, power source, and headless mode can affect rendering. Generate and compare snapshots in the same environment where possible; use separate baselines when platform differences are intentional.

What changes for a team in India?

The available official sources do not show that being in India makes Chrome Headless or Playwright intrinsically faster, cheaper, more reliable, or more accurate. Do not choose from geography alone. Decide these practical points instead:

  1. Where captures run: developer laptops, a CI runner, or a hosted capture service. Network path and machine resources can affect page load time, but the dossier does not provide an India-specific comparison.
  2. Which browser matters: bundled Chromium, current branded Chrome, or several browser engines.
  3. Which viewport matters: a desktop layout, a mobile-sized viewport, or both. A viewport emulates dimensions; it does not make every screenshot equivalent to a physical device.
  4. How visual references are maintained: keep operating system, browser version, fonts, settings, and headless mode stable between baseline creation and comparison.
  5. How much automation is needed: direct CLI capture is simpler for a fixed URL; Playwright handles navigation, state changes, and assertions in one script.

Options and edge cases that affect screenshot output

Browser and headless mode

“Headless” does not identify one universal rendering implementation. Playwright documents a regular Chromium build and a separate Chromium headless shell for its default headless mode. It also supports a newer Chrome-like headless mode through the chromium channel; behavior may differ from the shell. Match the mode to the browser behavior under test, then keep it fixed for repeatable output. See Playwright’s browser documentation.

Viewport, scale, and full page

Set the viewport deliberately. In Playwright, viewport controls CSS viewport dimensions and deviceScaleFactor controls pixel density. In Chrome CLI, --window-size sets the requested window dimensions. Full-page capture and viewport capture answer different questions: use full-page for page-wide review, viewport for the visible fold or a consistent component state.

Dynamic content and lazy loading

Network-idle is not a universal readiness signal. Pages may continuously poll, load advertisements later, animate, or lazy-load below the fold. Wait for the specific content that matters, scroll through lazy sections if necessary, and avoid relying on arbitrary long delays where a selector can define readiness.

Fonts and operating system dependencies

Missing fonts or system libraries can change layout or prevent browser launch in CI. Install the browser and system dependencies using the official Playwright installation guidance, and use a consistent runner image for visual comparisons. On Linux, browser installation and dependency installation may be separate steps depending on the environment.

Troubleshooting

Symptom Likely cause Fix
Chrome reports that it cannot open a display or fails to launch Chrome was launched without headless mode, or the environment lacks required browser dependencies. Confirm --headless is present; install the browser’s required system packages for the runner.
Chrome fails in a container with a sandbox error The container’s user or sandbox configuration is incompatible. Use the container’s supported sandbox configuration; where appropriate, add --no-sandbox and understand the security tradeoff for that isolated environment.
The screenshot is blank or only shows a loading shell Capture happened before client-side content became visible, or navigation reached an error/interstitial page. Wait for a meaningful selector, inspect the response and page state, and use a bounded timeout appropriate to the site.
Some images are missing in a full-page capture Images may load lazily only after scrolling into view. Scroll through the page before capture or wait for the needed images to load, then capture.
page.goto times out The site is slow, keeps network activity open, or did not reach the chosen lifecycle event in time. Choose the lifecycle event that matches the task, set a realistic timeout, and wait for the required selector separately.
Playwright says the browser executable is missing Browser binaries were not installed, or Playwright was upgraded without refreshing them. Run npx playwright install chromium (or install the required browsers) after package installation and after Playwright updates.
Visual snapshots differ only in CI Host OS, browser revision, fonts, hardware, settings, or headless mode differs from the baseline environment. Run comparison and baseline generation in the same environment; inspect platform-specific differences before updating references.
Branded Chrome fails under company management Enterprise policy can constrain browser automation. Check the managed browser policy and use bundled Chromium if branded Chrome is not required for the test.

Performance, reliability, and cost

No benchmark in the available sources establishes a speed winner for India or elsewhere. For a single screenshot, Chrome’s direct command has fewer application-level steps to configure. Playwright adds a browser automation runtime but supports richer workflows and reusable setup. Actual capture time depends on the target page, browser, host, network, and readiness condition; measure on the intended runner if latency matters.

For repeatability, pin the Playwright package and install its matching browsers, control the runner image and fonts, and use stable selectors or application readiness signals. A timeout makes a capture bounded, but it does not make a failed or partial navigation a valid screenshot; record failures and inspect the captured state. For visual tests, treat baseline updates as reviewed changes.

Both approaches can run on machines and CI you already operate; costs therefore depend on that environment and its resource use. The source material does not establish a specific India cloud price or operating cost. If maintaining browser binaries, dependencies, and capture infrastructure is the work you want to avoid, ScreenshotNeo offers a hosted screenshot API and MCP server at screenshotneo.com.

Or skip the browser setup

ScreenshotNeo accepts one GET request with a URL and returns an image or PDF. Its API supports PNG, JPEG, and WebP output, and the parameter names used by other screenshot APIs also work. See the ScreenshotNeo API documentation.

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

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com',
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
  • Cookie banners and consent prompts are accepted or removed before the shot; newsletter popups and chat widgets are removed too. Each step can be turned off.
  • Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers report the page verdict and billing status.
  • An MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs.
  • The free plan includes 1,000 screenshots a month with no card. Paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free 1,000 screenshots a month, with no card required.

Frequently asked questions

Can Playwright take a screenshot using Chrome?

Yes. Playwright can launch Chromium and can be configured for supported branded Chrome with the chrome channel. That gives you Playwright’s automation API while selecting the browser channel relevant to your test.

Is Chrome Headless a separate browser?

It is a way to run Chrome without visible UI. Chrome’s current Headless mode shares Chrome’s code; the older implementation has been distributed as a separate shell binary since Chrome 132.0.6793.0.

Which should I use for visual regression tests?

Playwright Test is the direct fit when you want screenshot assertions and managed reference images. Keep the browser and host environment consistent so rendering differences do not create noisy comparisons.

Does India change which tool I should choose?

The cited official documentation does not support an India-specific winner. Choose from workflow, browser fidelity, and the environment where captures will run.

Sources