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

Puppeteer can configure whether a browser context allows page-triggered downloads and where allowed files are saved, but its Files guide says Puppeteer does not provide a programmatic API to handle downloaded files. Set the context’s download behavior, trigger the download in the page, then use your runtime’s filesystem tools to check the resulting file if your browser setup supports that workflow.

What Puppeteer does—and does not—provide for downloads

The Puppeteer Files guide states: “Currently, Puppeteer does not offer a way to handle file downloads in a programmatic way.” That means there is no documented Puppeteer method here that returns a downloaded file or manages it as a file object. Puppeteer documents file uploads separately: an automation script can locate a file input and call ElementHandle.uploadFile. Upload support is not download support. Puppeteer: Files

The download-related API configures browser-context behavior. It does not, by itself, provide a download-completion callback or a way to read the file’s contents. After configuring the browser, the page still has to initiate a download, and any verification or file processing is an implementation pattern using filesystem facilities available in your runtime and browser setup.

Configure the browser context’s download behavior

Puppeteer’s API reference defines a downloadBehavior option for browser-context options. Its behavior object has a policy and an optional downloadPath. A writable destination path is required when the policy is allow or allowAndName. With allowAndName, the browser names downloads according to their download GUIDs rather than their original filenames. DownloadBehavior API · BrowserContextOptions API

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

Choose a policy

Policy Effect Path requirement
deny Disallow downloads. None stated.
allow Allow downloads, using the browser’s normal naming behavior. Set downloadPath.
allowAndName Allow downloads and name files using their download GUIDs. Set downloadPath.
default Use the browser’s default download behavior. None stated.

The policy values are documented in Puppeteer’s DownloadPolicy API. If you leave downloadBehavior unset, the browser’s default behavior applies. BrowserContextOptions API

Example with browser-context options

This example shows the documented BrowserContextOptions shape. It illustrates configuration only: it does not wait for completion or return the downloaded file. The current API references surfaced for this guide identify Puppeteer 25.12.0; check the documentation for your installed version and browser/protocol before using it.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const context = await browser.createBrowserContext({
  downloadBehavior: {
    policy: 'allow',
    downloadPath: '/tmp/puppeteer-downloads',
  },
});

const page = await context.newPage();
await page.goto('https://example.com/report', { waitUntil: 'domcontentloaded' });

// Replace this with the action that starts a download on your page.
await page.click('a[href="/report.csv"]');

// Puppeteer does not provide a documented download-completion API here.
// Use filesystem facilities appropriate to your runtime and browser setup
// if you need to inspect the resulting file.

await browser.close();

Create the destination directory first and ensure the process running the browser can write to it. The code deliberately does not claim that clicking the link means the file has finished downloading.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Configuration when connecting to a browser

ConnectOptions also documents a downloadBehavior option that sets behavior for the context. That is a separate configuration route for a connected-browser setup; follow the API reference for the version and connection mode you use rather than assuming identical behavior across browsers or protocols. ConnectOptions API

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

How to wait for and verify a downloaded file

Puppeteer’s Files guide does not establish a built-in download-finished event or a universal file workflow. Treat completion detection as something your own runtime and browser setup must supply, not as a Puppeteer download API.

  1. Set policy: 'allow' or policy: 'allowAndName' and provide a writable downloadPath.
  2. Trigger the site’s download action, such as clicking its download link or submitting the relevant form.
  3. Use filesystem facilities in your environment to check for the expected file. For a completion check, avoid treating a file’s first appearance as proof that writing is finished; determine completion using a method supported by your particular setup.
  4. Validate the result for your use case—for example, check that the file exists, is non-empty, and can be parsed as the expected format.

Step 3 is an implementation pattern, not a promise that Puppeteer itself reports completion. If your test requires dependable completion signaling, use a browser/protocol-specific mechanism only after confirming it is supported by your installed Puppeteer and browser versions.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Or skip the browser setup

If the task is to capture a page as an image or PDF rather than download a file generated by the page, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return a screenshot or PDF; it is not a replacement for automating arbitrary page downloads.

For example, this cURL request saves a WebP screenshot of a URL. See the ScreenshotNeo API documentation for parameters and formats.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie banners and consent prompts, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses identify page verdict and billing status in headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

Common problems and fixes

The file does not appear

  • Check that the page action actually starts a download rather than opening a preview or navigating to another page.
  • Confirm that the context uses an allowing policy and that downloadPath points to a writable directory.
  • Check the browser process’s permissions and the filesystem path as seen by that process, especially if the browser runs in a container or remote environment.

The downloaded filename is unexpected

With allowAndName, GUID-based filenames are expected. Use allow if you need the browser’s normal naming behavior, while remembering the API does not promise a Puppeteer method to retrieve or manage the resulting file.

The script continues before the download finishes

A click completing only confirms that Puppeteer completed the click action; it does not establish that the file download is complete. The documented download behavior option supplies policy and path configuration, not a completion callback. Add completion detection using facilities supported by your particular runtime and browser setup.

The API option is missing or behaves differently

Check the API reference for the installed Puppeteer version and how the browser was launched or connected. The documented context and connection options describe configuration, but do not establish identical behavior for every browser or protocol.

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

Do not confuse page downloads with installing Chrome

Installing Puppeteer can download a browser binary, but that is separate from a website downloading a file during automation. The puppeteer package downloads a compatible Chrome for Testing binary during installation. Starting with Puppeteer v19.0.0, the documented default cache is $HOME/.cache/puppeteer. By contrast, puppeteer-core does not download Chrome and is intended for cases where you connect to a remote browser or manage browser installation yourself. Puppeteer: Installation

Frequently Asked Questions

Can Puppeteer return the downloaded file as a buffer?

The Files guide does not document an API that returns a downloaded file or handles it as a file object.

Does setting downloadPath make Puppeteer wait for the download?

No. The documented option configures browser-context behavior and destination; it does not provide a completion callback.

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.

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