The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Use Playwright’s Node.js API inside a Docker container: launch a browser, navigate to the URL, and call page.screenshot(). The official Playwright image provides browsers and their system dependencies, but your project must install the Playwright package at a version aligned with the image. The example below saves a viewport screenshot to a mounted host directory; set fullPage: true for the full scrollable page.
Choose the screenshot area and output
| Need | Playwright option | Result |
|---|---|---|
| What is currently visible | page.screenshot({ path: 'screenshot.png' }) |
Saves a viewport screenshot; the default is not the entire scrollable document. |
| Entire scrollable document | page.screenshot({ path: 'screenshot.png', fullPage: true }) |
Captures the full page rather than only the viewport. |
| One component or region | locator.screenshot({ path: 'element.png' }) |
Captures the selected locator’s element. |
| Image bytes for another operation | const buffer = await page.screenshot() |
Returns a Buffer instead of requiring a file path; useful for an upload or image-processing step. |
Playwright documents these screenshot forms in its Screenshots guide and Page API. The runnable example uses a file because it is straightforward to retrieve from Docker.
Run a screenshot script in the official Playwright Docker image
The official image includes Playwright browsers and their system dependencies, but not the Playwright package for your project. Install the package separately, and keep its version aligned with the image: a mismatch can leave Playwright unable to locate the browser executable. The Docker documentation page showed version 1.63.0 tags, including v1.63.0-noble, v1.63.0-jammy, and v1.63.0-resolute when checked for this article; these are examples of tags shown then, not a claim that they will remain current. See Playwright’s Docker documentation for current guidance.
1. Create the project files
In a new directory, create package.json:
{
"name": "playwright-docker-screenshot",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"screenshot": "node screenshot.js"
},
"dependencies": {
"playwright": "1.63.0"
}
}
Create screenshot.js beside it:
import { chromium } from 'playwright';
const url = process.env.TARGET_URL ?? 'https://example.com';
const output = process.env.OUTPUT_FILE ?? '/output/screenshot.png';
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
const response = await page.goto(url, {
waitUntil: 'load',
timeout: 30_000,
});
if (!response) {
throw new Error(`Navigation returned no HTTP response for ${url}`);
}
if (!response.ok()) {
throw new Error(`Navigation failed: HTTP ${response.status()} for ${url}`);
}
await page.screenshot({ path: output, fullPage: true });
console.log(`Saved ${output} (${response.status()})`);
} finally {
await browser.close();
}
This waits for the page’s load event, then captures the full scrollable page. Some sites continue rendering content after that event; if a specific element marks readiness, wait for it before capturing, as shown in the troubleshooting section. Set fullPage to false or remove it to capture just the configured viewport.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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.
2. Build a version-matched image
Create Dockerfile:
FROM mcr.microsoft.com/playwright:v1.63.0-noble
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev
COPY screenshot.js ./
CMD ["npm", "run", "screenshot"]
Build the image:
docker build -t playwright-screenshot .
The package version in package.json and the Docker image tag are both pinned to 1.63.0 here. Before adopting the example, check the current Playwright Docker documentation and select an available image tag that matches the package version used by your project.
3. Save the artifact on the host
Create an output directory and run the container with it mounted at /output:
mkdir -p output
docker run --rm
-e TARGET_URL=https://example.com
-e OUTPUT_FILE=/output/screenshot.png
-v "$PWD/output:/output"
playwright-screenshot
After the command finishes, the image should be at output/screenshot.png in the current directory. The bind mount is important: without it, the file remains inside the container and is removed when a --rm container exits. This command uses a POSIX-style shell; adapt the volume syntax if you run Docker from a different shell or operating system.
Rank #2
- 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.
Adjust readiness, full-page capture, and element screenshots
Wait for a known element
For a page that renders its content asynchronously, replace or supplement the load-event step with a condition meaningful to that site:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallawait page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30_000 });
await page.locator('main h1').waitFor({ state: 'visible', timeout: 15_000 });
await page.screenshot({ path: output, fullPage: true });
Use a selector that exists only when the content you need is ready. A selector timeout is an explicit failure rather than a successful-looking screenshot of a loading state. If the page has no reliable marker, a deliberate delay can be used, but it adds fixed time and does not guarantee readiness.
Capture a single element
After navigating and waiting for the target component, capture its locator instead of the page:
Rank #3
- 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.
const card = page.locator('.product-card').first();
await card.waitFor({ state: 'visible' });
await card.screenshot({ path: '/output/product-card.png' });
Use a selector appropriate to the site. If it matches multiple elements, choose one explicitly (for example, with first()) or select by a more specific locator.
Return bytes instead of writing a file
For an upload or image-processing pipeline, omit path and consume the returned Buffer:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsconst buffer = await page.screenshot({ fullPage: true });
// Pass buffer to your upload or image-processing code.
When using this form in Docker, ensure the next step sends or stores the bytes before the process exits.
Rank #4
- 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
Build a custom Docker image when needed
A custom base image can suit an application that cannot use the official Playwright image, but it must provide Node.js, Playwright browsers, and the browsers’ system dependencies. Playwright’s Docker documentation illustrates a Node 20 Bookworm base and an installation command using Playwright 1.63.0; check current versions and adjust the base and package versions to match your project.
FROM node:20-bookworm
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev
&& npx -y playwright@1.63.0 install --with-deps chromium
COPY screenshot.js ./
CMD ["npm", "run", "screenshot"]
This installation example is version-specific and installs Chromium. A project using another Playwright version or browser should use the corresponding version and browser installation. The official image is generally the simpler starting point because it bundles browser binaries and their system libraries.
Handle container security appropriately
The official Playwright image runs as root by default; the Docker documentation says that this disables Chromium’s sandbox. Playwright describes root as potentially suitable for trusted end-to-end testing, but recommends a separate user and a seccomp profile so Chromium can run sandboxed for web scraping or crawling. Do not treat a successful screenshot from a root container as evidence that the browser is sandboxed. Follow the current Docker security guidance for the workload and environment, especially when visiting untrusted sites.
Best Value
- 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.
Common errors and fixes
| Symptom | Likely cause | What to check |
|---|---|---|
| Playwright cannot find a browser executable | The installed package version does not match the browser version in the image, or the browser was not installed in a custom image. | Align the package and image versions; for a custom image, install the corresponding browser binaries. |
page.goto() times out |
The site is slow, unreachable from the container, or waiting for the chosen navigation condition takes too long. | Check the URL and container network access, then choose an appropriate timeout and readiness condition. Do not hide persistent navigation failures by simply increasing the timeout indefinitely. |
| The screenshot is blank or shows a loading state | The capture ran before the page’s meaningful content appeared. | Wait for a site-specific visible selector before capturing; check that the selector matches the rendered page. |
| The output file is missing on the host | The output path is inside the container and was not mounted, or the container user cannot write to the mounted directory. | Mount the host output directory at the same path used by OUTPUT_FILE, and verify that the container can write there. |
| Screenshot differs across runs or machines | Rendering can vary with operating system, browser version, settings, hardware, power source, or headless mode. | Capture comparisons in the same environment as the baseline and keep browser/version and relevant settings consistent. |
| Browser launch fails in a custom image | Browser system libraries or other dependencies are missing. | Use the official image or install the browser dependencies as described in Playwright’s Docker documentation. |
Keep screenshot runs reliable and comparable
- Pin compatible versions: avoid floating image tags for repeatable builds, and keep the project package and Docker browser version aligned.
- Make readiness explicit: use a visible selector for the content you need rather than assuming every site is complete at the same navigation event.
- Keep the capture environment stable: Playwright notes that host OS, browser version, settings, hardware, power source, and headless mode can affect rendering. Use the same environment as the visual baseline. Its visual comparison guide says screenshot assertions wait for two consecutive screenshots to match before comparing, which helps avoid transient differences; see Visual comparisons.
- Set an intentional output path: write to a mounted directory when the host or a later job needs the artifact; use a Buffer when the next operation consumes it directly.
Or skip the browser setup
If you only need a screenshot from a URL, ScreenshotNeo offers a one-request alternative to managing Playwright and browser binaries in Docker. It can remove cookie banners, newsletter popups, and chat widgets before the capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000.
For example, this cURL request saves a WebP screenshot of Stripe:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. If the browser-based workflow is not necessary, ScreenshotNeo is worth considering for its clean shots, billing only for clean captures, and $5 entry paid plan. Sign up for ScreenshotNeo to get 1,000 screenshots a month free with no card.
Frequently asked questions
Does page.screenshot() capture the whole page by default?
No. The default screenshot is the viewport. Set fullPage: true to capture the full scrollable page.
Recommended Free Tools
Can I use a host-installed Playwright package with the container’s browser?
The script runs inside the container in this guide, so install the package there. Keep its version aligned with the Playwright image to avoid browser executable mismatches.
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.

