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

Symfony Panther’s documented $client->takeScreenshot('screen.png') captures the current page, but Symfony does not promise that it captures the full document height. For a long page, a community-reported workaround is to read the document’s scroll dimensions with JavaScript, resize the WebDriver window to those dimensions, then take the screenshot. Treat it as an environment-dependent workaround and verify the result in your browser and driver.

What Panther’s screenshot method does—and does not—guarantee

Panther controls real browsers through WebDriver and supports JavaScript execution. Symfony’s end-to-end testing guide shows $client->takeScreenshot('screen.png') for a screenshot of the current page, and explains that browser window dimensions control screenshot size. It does not document takeScreenshot() as a guaranteed full-document capture. Panther’s Client::takeScreenshot() implementation starts the client and delegates to the underlying WebDriver screenshot method, so behavior can depend on the browser and driver. See the Symfony Panther testing guide and Panther Client implementation.

Use window resizing as a long-page workaround

A reported approach measures document.documentElement.scrollWidth and scrollHeight, sets the browser window to those dimensions, and then calls Panther’s screenshot method. The sequence was described in Symfony Panther issue #587; it is not an official full-page Panther API or a cross-browser compatibility guarantee.

Runnable example

This example assumes Panther and its browser driver are installed and available, and that https://example.test/long-page is the page you want to capture:

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

use FacebookWebDriverWebDriverDimension;
use SymfonyComponentPantherClient;

$client = Client::createChromeClient();
$client->request('GET', 'https://example.test/long-page');

// Wait for a page-specific readiness condition before measuring if needed.
$width = $client->executeScript('return document.documentElement.scrollWidth');
$height = $client->executeScript('return document.documentElement.scrollHeight');

$client->manage()->window()->setSize(new WebDriverDimension($width, $height));
$client->takeScreenshot('long-page.png');

Replace the URL and output filename. If your page renders data asynchronously, add a wait for a meaningful element or other page-specific readiness condition before measuring. Panther supports JavaScript and element waits, but the cited documentation does not establish one universal signal that means every page is ready.

Why the dimensions come from the document

scrollWidth and scrollHeight estimate the document’s rendered width and height. Resizing the window to those values can make more of the page visible to the screenshot operation. Symfony’s guide demonstrates that window dimensions affect screenshot size, including a Chrome option such as --window-size=1500,4000 and a Firefox example that uses WebDriverDimension with setSize(). That documentation supports controlling the viewport; it does not guarantee that every browser and driver will produce a complete, correctly scaled image with the workaround.

Set up the browser and driver

Panther can create Chrome or Firefox clients and uses WebDriver. Install the browser and a compatible driver for the browser you select; Symfony’s guide discusses ChromeDriver and GeckoDriver, including the dbrekelmans/bdi driver installer option. Follow the current Symfony Panther installation and testing instructions for your project rather than assuming a particular driver version. The official Symfony Panther package listing showed version 2.4.0 when checked for this article; package versions change, so confirm the version available to your project.

Wait for dynamic content before measuring

The measurement is only useful if the page has reached the state you want to capture. If images, infinite-scroll content, charts, or client-rendered sections load after navigation, measuring immediately may return dimensions from an incomplete page. Wait for an element or application state that is meaningful for that specific page, then run the dimension script. For lazy-loaded pages, scrolling may be necessary to trigger content before measuring; the cited sources do not establish a universal lazy-load procedure, so validate against the target site.

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

Check the output and handle limits

  • Open the generated PNG and verify that the top, bottom, and full horizontal width are present; a successful file write alone does not prove it contains the entire document.
  • Try the workaround with the browser and driver used in your deployment. The issue report does not establish equivalent behavior for Chrome and Firefox or across browser and driver versions.
  • Very tall or wide pages can create large image dimensions. Browser or driver limits and memory behavior for exceptionally large pages are not established by the cited sources; split the capture or use a different method if the output is incomplete or the browser fails.
  • Pages that change layout after resizing may produce different wrapping or content than a normal viewport screenshot. Inspect the result at the intended dimensions.

Troubleshooting

The screenshot only shows the viewport

Confirm that the dimension script returned nonzero document dimensions and that setSize() ran before takeScreenshot(). The resize technique is a workaround, so if it still captures only the viewport, check the browser/driver combination and validate another approach rather than assuming Panther guarantees full-page capture.

The bottom of the page is missing

The page may not have finished loading or may append content only after scrolling. Wait for the relevant content and, where needed, trigger the page’s loading behavior before measuring. Then inspect the new dimensions and capture again.

The browser or driver rejects the requested size

Large document dimensions may exceed limits in a particular browser or driver; the sources do not specify a universal maximum. Test smaller sections or another browser/driver and verify the resulting image. Do not treat a successful resize call as proof that the full page was captured.

The page layout changes in the image

Resizing changes the viewport, which can activate different responsive breakpoints. If the target layout matters, choose a deliberate width and test it; the reported workaround measures the document width, which may differ from the viewport width used during ordinary browsing.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo offers a screenshot API and MCP server for developers. One GET request can return an image or PDF; this cURL example saves a WebP screenshot of the target URL:

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

See the ScreenshotNeo API documentation for authentication, output formats, and options. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can each be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.

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.