ScreenshotNeo

BlogComparisons

Selenium Screenshot vs Playwright Screenshot for Full-Page Web Captures

Playwright documents a direct full-page screenshot option; Selenium support depends on the browser and binding. Compare the APIs and choose the right capture method.

By the ScreenshotNeo team4 October 202610 min read

Short answer: For a full-page capture with Playwright, set fullPage: true. Selenium can also capture full pages in specific implementations, but its ordinary WebDriver screenshot method should not be assumed to do so in every browser and language binding. Check the exact browser-and-binding API you use.

This guide compares the documented capture scopes, output controls, and practical tradeoffs. It includes runnable examples for Playwright and Selenium, plus a PDF option and a hosted screenshot API when you do not need browser automation in your own code.

1. Which should you choose?

Need Practical starting point What to verify
One full, scrollable page image in Playwright Use page.screenshot({ fullPage: true }). Wait for the page state you intend to capture; full-page capture cannot be combined with Playwright’s target element option.
Full-page image through Selenium Use the browser-specific full-page API supported by your binding. Selenium Java documents HasFullPageScreenshot as Beta and lists FirefoxDriver; Selenium JavaScript’s Firefox driver has takeFullPageScreenshot(). Confirm support in the exact Selenium version, browser, and binding. The generic WebDriver screenshot examples capture the current browsing context and do not promise full-page behavior everywhere.
A printed document with pages Consider Selenium’s print-to-PDF API if its browser requirements fit. The Selenium interactions documentation says print-page requires Chromium running headless. Check page ranges, margins, layout, scale, and background options.
A screenshot without managing browser automation Use a screenshot service such as ScreenshotNeo. Review its capture options and response behavior in the API documentation.

The cited feature documentation does not establish a speed or visual-fidelity winner between Selenium and Playwright. Choose based on the browser and binding you need, the capture scope and output, and your existing automation stack.

2. What “full-page” means

A viewport screenshot records the visible browser area. A full-page screenshot extends the capture across the page’s scrollable content. An element screenshot targets a particular node, such as a chart or card. These scopes are not interchangeable: a long page can produce a very tall image, while a PDF is paginated for document-style output.

Playwright’s screenshot documentation describes viewport, element, and full-scrollable-page capture. Its fullPage: true option requests the full scrollable page. Selenium’s common WebDriver screenshot examples are for the current browsing context; browser-specific APIs are needed when you require guaranteed full-page behavior. See the official Playwright Screenshots documentation and Selenium references for Java full-page screenshots, the JavaScript Firefox driver, and general WebDriver screenshot examples.

3. Playwright: capture the entire scrollable page

Install Playwright for Node.js, create a page, navigate to the target, and pass fullPage: true to page.screenshot(). This example saves a PNG:

import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: true });
try {
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
  await page.goto('https://example.com', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'full-page.png', fullPage: true, type: 'png' });
} finally {
  await browser.close();
}

Install the package and browser with npm install playwright and npx playwright install chromium. Save the example as an ES module file such as screenshot.mjs and run node screenshot.mjs.

Playwright screenshot options that matter

  • fullPage: capture the full scrollable page. It cannot be combined with target, which selects an element.
  • target: capture a specific element when a whole-page image is unnecessary.
  • type: choose PNG, JPEG, or WebP output.
  • filename: choose where the screenshot file is written in the documented screenshot tool.
  • scale: choose CSS-pixel or device-pixel scale in the documented screenshot tool. Higher pixel density can increase image dimensions and file size.

The documentation at Playwright Screenshots describes those controls. If you use Playwright’s Node.js library directly, consult that library’s API for its option names and behavior; the tool documentation’s target and filename names are not necessarily the library method’s names.

4. Selenium: full-page support depends on the binding

Do not substitute the generic getScreenshotAs method for a full-page API without checking the implementation. Selenium’s Java HasFullPageScreenshot interface is marked Beta and names FirefoxDriver as an implementing class. Selenium’s JavaScript Firefox driver documents takeFullPageScreenshot(), returning a base64-encoded PNG. Confirm the current API in the documentation for your Selenium release.

Java with FirefoxDriver

The following uses Selenium’s documented Java full-page interface. It assumes Selenium Java and a compatible FirefoxDriver are available on the classpath, and that Firefox is installed.

import java.nio.file.Files;
import java.nio.file.Path;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.HasFullPageScreenshot;
import org.openqa.selenium.OutputType;

public class FullPageShot {
  public static void main(String[] args) throws Exception {
    WebDriver driver = new FirefoxDriver();
    try {
      driver.get("https://example.com");
      HasFullPageScreenshot fullPageDriver = (HasFullPageScreenshot) driver;
      byte[] png = fullPageDriver.getFullPageScreenshotAs(OutputType.BYTES);
      Files.write(Path.of("full-page.png"), png);
    } finally {
      driver.quit();
    }
  }
}

This API is documented as Beta. If the cast or method is unavailable, verify the driver class, Selenium version, and browser before changing your capture logic. Reference: Selenium HasFullPageScreenshot.

JavaScript with Selenium Firefox driver

The Firefox-specific JavaScript driver returns a base64 PNG. Decode it to bytes before writing the file.

const { Builder } = require('selenium-webdriver');
const firefox = require('selenium-webdriver/firefox');
const fs = require('node:fs/promises');

(async () => {
  const driver = await new Builder().forBrowser('firefox').build();
  try {
    await driver.get('https://example.com');
    const base64 = await driver.takeFullPageScreenshot();
    await fs.writeFile('full-page.png', Buffer.from(base64, 'base64'));
  } finally {
    await driver.quit();
  }
})();

Install the binding with npm install selenium-webdriver and configure a compatible Firefox installation and driver. This method is specific to Selenium’s Firefox driver; do not assume it exists on other driver classes. Reference: Selenium JavaScript Firefox Driver API.

Viewport screenshots in Selenium

For a viewport capture, Selenium’s normal screenshot method is appropriate. The general examples are documented across bindings in Selenium’s windows and tabs guide. A viewport screenshot and a full-page screenshot solve different problems; confirm the API scope before treating one as the other.

5. Use Selenium print-to-PDF for paginated output

If the deliverable is a document rather than one tall raster image, Selenium’s print-page feature can produce PDF output with print options such as page ranges, layout, scale, backgrounds, and margins. Selenium’s documentation says this feature requires Chromium browsers to run headless. See Selenium Print Page.

Choose PDF when readers need pages, printing, or document-oriented review. Choose a full-page PNG when you need one continuous image for visual comparison or image processing. Browser print styles can differ from the on-screen page, so inspect the result for your use case.

6. Stabilize the page before capturing

A screenshot records a browser state. Decide what state your test or archive should represent, then wait for that state explicitly. Common sources of inconsistent captures include late network responses, lazy-loaded images, animation, sticky headers, and pages that keep loading content as they scroll.

  1. Wait for useful content. Navigate using an appropriate load condition, then wait for a selector that represents the content you need. A quiet network is not always a reliable definition of readiness for pages with analytics, polling, or long-lived connections.
  2. Handle lazy loading deliberately. If content appears only after scrolling, scroll through the relevant page before capturing and allow images or sections to load. Avoid assuming that a navigation event alone makes every below-the-fold asset ready.
  3. Control animation when visual consistency matters. Disable or finish animations in your test setup where appropriate, and capture at a defined point in the interaction.
  4. Account for sticky elements. A sticky header may appear in repeated positions during a full-page capture depending on browser implementation. If the output is for visual comparison, inspect the result and set a consistent strategy.
  5. Settle infinite scrolling. An infinite page may never have a final length. Define a stopping point, such as a known item count or scroll limit, before taking a screenshot.

These are test-design practices; the cited API references document capture options, not guarantees about every site’s loading or layout behavior.

7. Output, scale, and capture scope

Choice Use it when Tradeoff to consider
Full page You need the page’s complete scrollable content in one image. Long pages create tall images that may be expensive to store, transmit, or inspect.
Viewport You need the visible state or a viewport-sized regression snapshot. It omits content outside the current viewport.
Element You need a chart, component, or region only. Playwright’s documented screenshot tool does not allow target together with fullPage.
PDF You need a paginated document. Printed output follows print behavior and the Selenium route documented here has a headless Chromium requirement.

For Playwright’s documented screenshot tool, PNG, JPEG, and WebP are available output types, and scale can be CSS pixels or device pixels. Prefer a smaller scale or a compressed format when file size matters, and use device-pixel scale when you need the additional raster detail and can accommodate the larger output.

8. Performance, reliability, and cost

The research sources provide no controlled Selenium-versus-Playwright benchmark for capture speed, memory, or visual fidelity. Those results depend on the browser, page, content, hardware, and capture settings. If those factors matter to your decision, measure representative pages in your own environment using the same browser version, viewport, readiness condition, and output format.

  • Performance: Full-page images can be large, especially at device-pixel scale. Limit captures to the page or element needed, and avoid repeatedly capturing unchanged pages when your workflow can reuse a result.
  • Reliability: Pin compatible browser and driver versions in automation, wait for an explicit page condition, and keep browser cleanup in a finally block so failed captures do not leave processes running.
  • Cost: Self-hosted automation uses your compute, storage, and maintenance time. The exact cost depends on your infrastructure and workload; the cited documentation does not provide a cross-tool price comparison. A hosted API trades browser setup and operations for a per-plan service cost.

9. Troubleshooting

Symptom Likely cause Fix
Playwright rejects the screenshot options fullPage and target were used together. Choose full-page capture or element capture for that call; the documented tool does not combine them.
Selenium screenshot contains only the viewport The generic screenshot method captures the current browsing context in that implementation. Use a documented full-page API for your exact browser and binding, or use a paginated PDF route if that is the required output.
ClassCastException for Selenium’s Java interface The active driver does not implement HasFullPageScreenshot, or the library/driver combination differs from the documented implementation. Check that you are using a supported FirefoxDriver and compatible Selenium version; consult the Beta interface documentation.
JavaScript says takeFullPageScreenshot is not a function The method is documented on Selenium’s Firefox driver, not as a universal WebDriver method. Build the Firefox driver and verify your Selenium JavaScript package and API version.
Screenshot is blank or missing below-the-fold images The page or its lazy content was not ready when capture began. Wait for a content selector, scroll through lazy sections, and allow their assets to load before capture.
Screenshot changes between runs Animations, dynamic content, sticky elements, or timing vary between captures. Make readiness and viewport conditions explicit; control animation or page data where your test permits it.
Full-page capture never settles on an infinite feed The page continues appending content as it scrolls. Set a maximum scroll depth or item count and capture that defined state.
PDF printing is unavailable or fails in Selenium The browser does not meet the documented Chromium headless requirement. Run a supported Chromium browser in headless mode and check the Selenium print-page options.

10. Or skip the browser setup

If you need a page image without managing Selenium or Playwright, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF. Its full-page option loads lazy images. The API also supports element capture, viewport and device presets, output controls, custom CSS and JavaScript, waiting conditions, and other capture settings; 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,
)
r.raise_for_status()
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 import('node:fs/promises').then(fs => fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer())));
  • Cookie banners are accepted and removed before the shot, and known newsletter popups and chat widgets can be removed; each cleanup step can be turned off.
  • Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. The response identifies the page verdict and billing status in headers.
  • An MCP server lets AI agents, including Claude, Cursor, and other MCP clients, take screenshots with the take_screenshot, get_page_info, and capture_pdf tools.
  • 1,000 screenshots a month are free with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan.

Sign up for ScreenshotNeo and get 1,000 screenshots a month free, with no card.

11. Frequently asked questions

Does Selenium support full-page screenshots in every browser?

No universal guarantee is established by the cited references. The Java full-page interface names FirefoxDriver and is marked Beta; the JavaScript method cited is on the Firefox driver. Check your exact implementation.

Can I capture one element and the full page in the same Playwright screenshot?

The documented screenshot tool does not combine target element capture with fullPage. Make separate captures if you need both outputs.

Should I use a full-page image or PDF?

Use a full-page image for one continuous raster capture. Use PDF when pagination and document-style output matter, while accounting for print styles and browser requirements.

Which tool is faster?

The official feature references cited here do not provide a comparative speed benchmark. Measure with the pages, browsers, and settings that match your workload.