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.

For a one-off capture, run Chrome Headless with --screenshot. For repeatable shell workflows, use Playwright CLI. For waits, loops, authentication, element captures, or image processing, use Playwright for Python. All three render the page in a browser, so JavaScript-heavy sites can be captured without opening a visible window.

Choose the right capture method

Method Best for Useful controls
Chrome Headless A single URL from a shell Viewport size, wait timeout, PNG output
Playwright CLI Repeatable command-line jobs Full-page, element, filename, PNG/JPEG/WebP, high-resolution output
Playwright Python Programs, batches, custom waits and post-processing Viewport, full-page, locator, buffer and asynchronous APIs

Command names and browser channels can change with installed versions. Check the official documentation for your version if a flag is rejected.

Take a screenshot with Chrome Headless

Chrome’s documented --screenshot flag writes screenshot.png in the current directory. Add --window-size to control the viewport and --timeout when the page needs more time before capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chrome --headless --screenshot --window-size=1440,900 https://example.com

On systems where the executable is named differently, use the installed Chrome or Chromium command (for example, an absolute path). The result is a viewport screenshot, not automatically a complete scrollable-page image. The command-line reference is at Chrome Headless CLI documentation.

Wait for a slow page

chrome --headless --screenshot --window-size=1440,900 --timeout=10000 https://example.com

--timeout controls how long Chrome waits before taking the shot. A longer timeout can allow client-side rendering to finish, but it does not guarantee that a page’s data requests or animations have reached the state you want. For precise conditions, use Playwright.

Use Playwright from the command line

Playwright CLI runs headless by default. Open a page, then capture the current page:

playwright-cli open https://example.com
playwright-cli screenshot --filename=example.png

For a complete scrollable page:

playwright-cli open https://example.com
playwright-cli screenshot --full-page --filename=example-full.png

The screenshot command reference documents output types and high-resolution capture:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
playwright-cli screenshot --type=webp --hires --filename=example.webp

Supported documented types are png, jpeg and webp. You can also target an element by its recorded reference or selector, depending on the CLI interaction flow. See Playwright CLI documentation and the screenshot command reference for the current syntax.

When CLI is preferable

  • You want named output files in a shell script.
  • You need full-page or element captures without writing a program.
  • You want WebP or JPEG instead of the default PNG.
  • You are building a repeatable job but do not need application logic around navigation.

Capture a website with Playwright Python

Install Playwright in your Python environment, install its browser binaries, then run this synchronous example:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 900})
    page.goto("https://example.com")
    page.screenshot(path="screenshot.png")
    page.screenshot(path="full-page.png", full_page=True)
    page.locator("header").screenshot(path="header.png")
    browser.close()

page.screenshot(path="screenshot.png") saves the visible viewport. Setting full_page=True captures the page’s full scrollable height. A locator can capture only one element. These are documented in Playwright Python screenshots.

Wait for JavaScript content

Do not rely on an arbitrary sleep when the page exposes a meaningful readiness condition. Wait for a selector that appears after rendering:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.goto("https://example.com/dashboard", wait_until="domcontentloaded")
page.locator("main.dashboard").wait_for(state="visible")
page.screenshot(path="dashboard.png", full_page=True)

If the site has a known API response, wait for that response or for the resulting UI element. A fixed delay can be useful as a last resort, but it is slower on fast runs and still unreliable on slow ones.

Save bytes in memory

image_bytes = page.screenshot(type="png")
with open("screenshot.png", "wb") as f:
    f.write(image_bytes)

The asynchronous API uses async_playwright and await with the same screenshot options, which is useful when capturing many URLs concurrently under a controlled limit.

Viewport, full-page and element captures

Viewport shots

A viewport screenshot represents what a user sees at the selected width and height. Set the viewport explicitly so runs are reproducible; otherwise host or browser defaults can change the composition.

Full-page shots

Playwright’s full_page option stitches the page’s scrollable content. Very tall pages can create large images and may expose lazy-loading behavior, sticky headers or content that only appears after scrolling. If images load on scroll, scroll or otherwise trigger the page before capturing, and verify that the layout has settled.

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

Element shots

Use a locator for a component such as a header, chart or invoice. Prefer a stable selector such as a data attribute over a generated class. If the locator matches multiple elements, narrow it or choose the intended match before calling screenshot.

Dynamic pages and browser choices

A screenshot is a browser-rendering task, not simply an HTTP download. JavaScript, fonts, consent dialogs, animations, authentication and bot protection all affect the pixels. Chrome Headless provides a timeout; Playwright lets your program wait for selectors and other conditions.

Playwright distinguishes its bundled Chromium builds from branded Chrome or Edge channels. Its browser documentation also covers headless-shell installation options; consult the browser guide when a site behaves differently in your local browser than in bundled Chromium.

  • Disable or await animations when a moving element makes captures inconsistent.
  • Use a deterministic viewport and timezone when visual comparisons matter.
  • Supply login state only through a secure, temporary context; never hard-code credentials in a script.
  • Expect CAPTCHA or bot-check pages to produce a challenge rather than the intended content.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF, while its capture process accepts cookie banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before the shot. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing 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 the complete parameter list, see the ScreenshotNeo documentation. A cURL request is:

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)
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}`);

Options include full-page and CSS-selector captures, dark mode, device presets or custom viewports, retina scale, PDFs, custom CSS and JavaScript, pre-capture clicks, waits, blocked requests, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks and bulk calls for up to 100 URLs. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

Every feature is included on every plan: 1,000 shots per month free with no card; paid plans start at $5 for 3,000 shots. Yearly billing provides two months free. Create a free ScreenshotNeo account.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

“Command not found”

Chrome or Playwright is not on your PATH. Install the chosen tool, use its documented browser-install step, or call the executable with its full path.

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

The output is blank or incomplete

The page may render after your capture, require scrolling, or have failed requests. Increase Chrome’s timeout, or in Playwright wait for a visible, page-specific selector and use full_page=True where appropriate.

A cookie dialog covers the page

Click or dismiss it in Playwright before the screenshot, or hide the selector with page scripting. For automated captures where consent cleanup is important, ScreenshotNeo removes supported consent banners, popups and chat widgets before capture.

Full-page output is unexpectedly huge

Long feeds, unbounded containers and lazy content can create very large images. Capture a specific element, constrain the page, or produce a PDF with appropriate page settings.

Element capture fails

The selector may match nothing, be hidden, or be inside a frame. Wait for visibility, use a stable selector, and address the correct frame before calling the locator screenshot.

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

Different machines produce different pixels

Pin browser and Playwright versions where possible, set viewport and relevant locale or timezone values, and avoid capturing during animations. Bundled Chromium and branded Chrome can also differ; select the channel deliberately.

Practical reliability and cost notes

  • Write captures to unique filenames in batch jobs so parallel runs do not overwrite one another.
  • Record the URL, viewport, browser version and timestamp alongside each image for later comparison.
  • Retry transient navigation failures with a limit and backoff, but do not blindly retry authentication or CAPTCHA pages.
  • Use PNG for lossless UI comparison, JPEG for photographic pages, and WebP when a smaller modern image is acceptable.
  • For many URLs, control concurrency to avoid exhausting memory; close each page and browser context promptly.

Which approach should you use?

  1. Use Chrome Headless when you need one straightforward viewport shot.
  2. Use Playwright CLI when a shell script needs full-page, element, filename or format controls.
  3. Use Playwright Python when navigation state, waits, batches, authentication or post-processing belong in code.
  4. Use ScreenshotNeo when you want an API or MCP workflow without maintaining browser setup and want failed or unclean captures identified before billing.

Frequently Asked Questions

Can I take a screenshot without opening a visible browser window?

Yes. Chrome Headless and Playwright run in headless mode, so rendering occurs without a browser window.

What is the difference between a viewport and a full-page screenshot?

A viewport shot captures the selected visible dimensions; a full-page Playwright shot captures the page’s entire scrollable content.

Can screenshots include a single page element?

Yes. Playwright Python can call locator.screenshot(), and Playwright CLI supports targeted element captures.

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

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.