How to Capture a Full-Page Screenshot with Playwright on Ubuntu in India
Capture an entire webpage with Playwright on Ubuntu: install Chromium and Linux dependencies, save full-page images, and fix common setup issues.
Use Playwright’s page.screenshot() method with fullPage: true. On Ubuntu, install the Chromium build that matches your Playwright package and its Linux dependencies, navigate to the page, and save the screenshot. The procedure is the same in India as elsewhere; the official documentation does not describe an India-specific setup.
1. Check the supported environment
Playwright’s current installation documentation lists Ubuntu 22.04, 24.04, and 26.04 on x86-64 or arm64, and Node.js 22.x, 24.x, or 26.x. Check the requirements for the Playwright version you install, since supported versions can change. Playwright installation requirements.
Playwright browser binaries are tied to Playwright package versions. After upgrading the package, install its corresponding browser binaries again if needed. Browser installation and dependencies.
2. Install Playwright and Chromium
In a new project, install Playwright and then Chromium with its system dependencies:
mkdir playwright-full-page
cd playwright-full-page
npm init -y
npm install playwright
npx playwright install --with-deps chromium
The --with-deps option installs the Linux packages Chromium needs along with the browser. If Playwright is already installed, run that last command from the project directory. To install dependencies separately, use npx playwright install-deps chromium; to install the browser without dependencies, use npx playwright install chromium.
For headless-only workflows, Playwright also documents npx playwright install --with-deps --only-shell chromium, which installs Chromium’s headless shell. Use it only if your workflow is compatible with that browser option.
3. Capture the full page
Create capture.mjs in the project directory:
import { chromium } from 'playwright';
const url = process.argv[2] ?? 'https://example.com';
const browser = await chromium.launch();
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(url, { waitUntil: 'load', timeout: 60_000 });
await page.screenshot({ path: 'full-page.png', fullPage: true });
} finally {
await browser.close();
}
Run it with a target URL:
node capture.mjs https://example.com
fullPage: true captures the page’s full scrollable height as if it were one tall screen, instead of capturing only the current viewport. The example uses a 1440 × 900 viewport to make the page layout predictable; change it to match the viewport you need. See the Playwright screenshot guide and Page API.
4. Choose the output and capture behavior
- Format: Set
type: 'png'ortype: 'jpeg'in the screenshot options. The default is PNG. JPEG is lossy; use PNG for lossless output. The API also documents supported screenshot options and formats. - Scale: Set
scale: 'css'for output dimensions based on CSS pixels, orscale: 'device'for device pixels. Device scale can produce larger files. - Viewport: Set viewport width and height when creating the page. Responsive layouts can differ substantially at different widths.
- Wait for content: If the page renders content after load, wait for a known selector or a deliberate short delay before taking the screenshot. Prefer a selector that indicates the content you need is ready over an arbitrary long sleep.
- Long or dynamic pages: Full-page capture can be large, and pages with sticky elements, animations, lazy loading, or content that changes while scrolling may not look like one continuous viewport. Check the resulting image and handle page-specific behavior where necessary.
- Selected element: If you only need a component, locate it and use the locator screenshot method instead of capturing the entire page. This avoids capturing unrelated page content.
5. Ubuntu and network troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Browser executable is missing | The browser binary was not installed for this Playwright package version. | Run npx playwright install chromium in the project, then retry. |
| Shared library or missing dependency error | Chromium’s Linux system dependencies are absent. | Run npx playwright install --with-deps chromium. If installing the browser separately, use npx playwright install-deps chromium. |
| Browser download is slow or fails | A restricted or slow network may interfere with downloads from Microsoft’s CDN. | Follow Playwright’s documented proxy setup using HTTPS_PROXY. For slow connections, set PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT. If a proxy uses a custom certificate authority, configure NODE_EXTRA_CA_CERTS. For proxy-based Linux dependency installation, the docs advise running as root so environment variables reach the package manager. |
| Screenshot contains only the initial content | The site may render content asynchronously, or the capture may happen before the needed content appears. | Wait for the relevant selector or content state before calling screenshot(); check that navigation did not time out first. |
| Image layout differs between runs or machines | Rendering can vary with host OS, browser version, settings, hardware, power source, and headless mode. | Use the same environment and browser version for visual comparisons. See Playwright visual comparisons. |
| Image is unexpectedly huge | A full-page image includes the entire document height, and device-pixel scaling can multiply dimensions. | Use CSS scale where suitable, capture a specific element, or split the task into page sections if your downstream workflow supports it. |
There is no documented India-only download or browser setup path. If access to browser downloads is restricted on your network, use the generic proxy guidance in the Playwright browser documentation; do not assume a regional block without evidence.
6. Reliability, performance, and cost
For repeated captures, pin the Playwright package version and install its matching browser during environment setup. Reuse the same environment for comparable output. Navigation timeouts, remote site responsiveness, page length, and rendering work affect how long a capture takes; large full-page images also take more memory and storage than viewport captures. Select only the browser engine you need to avoid downloading unnecessary browser builds.
Playwright is an open-source browser automation library; this workflow has no per-screenshot API charge described by the cited Playwright documentation. You still provide and operate the machine, network, and storage. In CI, follow the project’s continuous integration guidance for installing browsers and dependencies.
7. When the goal is visual regression testing
For a one-off image, page.screenshot() is the direct method. For repeatable visual assertions, Playwright Test provides toHaveScreenshot() to compare against a reference image. Keep the operating system, browser version, and relevant settings consistent because they can affect rendered pixels. See the visual comparison guide.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request captures a URL as PNG, JPEG, WebP, or PDF. Its API documentation covers parameters; the basic call is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Python:
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)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Cookie banners, newsletter popups, and chat widgets are removed before the shot, and each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for free and get 1,000 screenshots a month with no card.
FAQ
Does capturing a full page work differently in India?
The cited official Playwright documentation does not identify a different procedure or regional limitation for India.
Does fullPage: true scroll the page visibly?
It captures the full document as if the page had a very tall screen. It is not just a screenshot of the current viewport.
Should I use PNG or JPEG?
Use PNG when you want lossless output; choose JPEG when lossy compression is acceptable. Neither format changes how the page is rendered.
Why do screenshots differ across computers?
Operating system, browser version, settings, hardware, power source, and headless mode can all affect rendering. Standardize the environment when comparing images.


