October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Take a Website Screenshot with Playwright in Node.js Inside Docker

A practical guide to capturing viewport, full-page, or element screenshots with Playwright in Node.js inside Docker, including image compatibility and security.

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.

Use Playwright’s Node.js API to open a page and call page.screenshot(). In Docker, the key setup detail is to install the Playwright package separately and keep its version aligned with the browser image. The example below captures the visible viewport; add fullPage: true for the full scrollable page or capture a specific locator when you only need one element.

Capture a website screenshot with Playwright in Node.js

Install Playwright in your project, launch Chromium, navigate to a URL, and save the screenshot. This minimal script writes screenshot.png to the container’s current working directory:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'load' });
    await page.screenshot({ path: 'screenshot.png' });
  } finally {
    await browser.close();
  }
})();

The default capture is the current viewport, not the entire document. Playwright’s screenshot API accepts a file path or returns image bytes. See the Playwright screenshots guide and Page API.

Capture the full page

Use fullPage: true when the output should include the full scrollable page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
await page.screenshot({ path: 'full-page.png', fullPage: true });

Capture one element

Take a locator screenshot to isolate a component rather than the viewport:

await page.locator('.product-card').screenshot({ path: 'product-card.png' });

Replace .product-card with a selector present on the target page. Locator screenshots wait for the selected element to be actionable and capture the element itself.

Return a buffer instead of writing a file

Omit path to receive a Node.js Buffer. This is useful when passing the image to an upload client or image-processing step:

const image = await page.screenshot();
// Pass image to an upload or image-processing function.

Run the script in Docker

The official Playwright Docker image contains browser binaries and their system dependencies, but it does not include the Playwright Node.js package. Install that package in the project, and use an image version matching the package version so Playwright can locate its browser executable. The Playwright Docker documentation recommends pinning a specific image version rather than relying on a floating tag.

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

Use the official versioned image

A minimal Dockerfile for a project that already contains package.json and package-lock.json is:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
FROM mcr.microsoft.com/playwright:v1.63.0-noble

WORKDIR /app
COPY package*.json ./
RUN npm ci && npx playwright install --with-deps chromium
COPY . .
CMD ["node", "screenshot.js"]

In this example, make sure the installed project dependency is Playwright 1.63.0 to match the image tag. The Docker documentation showed tags including v1.63.0-noble, v1.63.0-jammy, and v1.63.0-resolute when its documentation was retrieved; check the current Playwright Docker page and use a tag appropriate to your project before building. The install command above explicitly installs Chromium; use the matching package version in your dependency manifest.

Build and run from the directory containing the Dockerfile and project files:

docker build -t playwright-shot .
docker run --rm playwright-shot

The screenshot is saved inside the container at /app/screenshot.png. This example does not mount a host directory, so the file disappears when the container is removed. If you need the artifact on the host, configure a volume mount and save to its mounted path; choose a path that matches your environment rather than assuming one universal host path.

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

Use a custom Node.js image

If you need a different base image, it must provide Node.js, Playwright browser binaries, and the browsers’ system dependencies. Playwright’s Docker documentation gives a Node 20 Bookworm base and an install flow using npx -y [email protected] install --with-deps. Adapt the version to the Playwright package used by your application and verify the current documentation before adopting a version-specific setup.

Choose when the page is ready to capture

page.goto() can wait for a navigation lifecycle state, but a page may continue changing after that point—for example, when it renders content asynchronously. If a specific element indicates readiness, wait for it before taking the screenshot:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
await page.goto('https://example.com', { waitUntil: 'load' });
await page.locator('main h1').waitFor({ state: 'visible' });
await page.screenshot({ path: 'ready.png' });

Use a selector that is meaningful for the page you are capturing. For a known fixed delay, Playwright also supports an explicit timeout, but waiting for a page condition is generally more robust than guessing how long a site needs to load.

Run Chromium with the right security boundary

The Playwright Docker image runs as root by default, which disables Chromium’s sandbox. The Docker documentation says that can be suitable for trusted end-to-end tests. For scraping or crawling untrusted sites, it recommends using a separate user and a seccomp profile so Chromium can run sandboxed. Treat pages you do not control as untrusted; do not assume the default root configuration provides browser sandboxing. See the Docker security guidance for the documented setup.

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

Keep screenshots reliable for comparison

Rendering can vary with the host operating system, browser version, settings, hardware, power source, and headless mode. For visual regression work, capture both the baseline and new image in the same environment and keep the browser version and relevant settings consistent. Playwright’s visual comparisons guide says screenshot assertions wait for two consecutive screenshots to match before comparing, which helps avoid transient capture differences; it does not make captures across different environments identical. See Visual comparisons | Playwright.

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

Troubleshoot common Docker screenshot failures

Playwright cannot find the browser executable

Cause: The Playwright package version and the Docker image’s browser version do not match, or the browser was not installed for the package in a custom image.

Fix: Pin a versioned image and align the project’s Playwright package with it. For a custom image, install the browser binaries and system dependencies using the Playwright install command for that same package version.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The script runs, but the screenshot is missing on the host

Cause: The script saved the image inside the container filesystem, which is removed when a --rm container exits.

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.

Fix: Save under a mounted volume path and configure the host-to-container mount when running Docker. Confirm the in-container destination matches the path passed to page.screenshot().

The image is blank or misses late-loading content

Cause: Navigation completed before the relevant content appeared, or the screenshot captured the viewport while the desired material was farther down the page.

Fix: Wait for a page-specific visible selector before capturing. Set fullPage: true if you need the full scrollable document rather than the viewport.

Chromium sandboxing is disabled

Cause: The documented default Docker image runs as root, which disables Chromium’s sandbox.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Fix: For untrusted crawling or scraping, configure a separate user and the recommended seccomp profile. Do not treat the trusted-test default as the secure choice for arbitrary websites.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return an image or PDF, without building and maintaining the browser container for this capture:

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

See the ScreenshotNeo API documentation for options and response details. It can accept cookie or consent banners like a visitor and remove 60+ known consent platforms, 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 response headers say which verdict applied and whether the shot was billed. 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 a month with no card; paid plans start at $5 for 3,000 shots.

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

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

Frequently Asked Questions

Can Playwright save a screenshot without a file path?

Yes. Call page.screenshot() without path; it returns a Buffer.

Does fullPage: true capture a single element?

No. It captures the full scrollable page. Use a locator’s screenshot() method to capture one element.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.