Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

Puppeteer Browser API: How to Manage Page Downloads

Puppeteer can configure browser-context download behavior and destination, but its Files guide does not offer programmatic file-download handling. Learn the policy options, path requirements, verification pattern and common pitfalls.
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 it does not provide a programmatic API for handling downloaded files. Set a download policy and, when required, a writable path; then use filesystem tools in your runtime to inspect the result. This is separate from installing Puppeteer’s browser executable.

What Puppeteer can and cannot do with downloads

The Puppeteer Files guide states: “Currently, Puppeteer does not offer a way to handle file downloads in a programmatic way.” Puppeteer Files guide That means Puppeteer does not document an API that returns a downloaded file or manages it as a file object. Its documented download-related controls configure browser behavior; they do not themselves provide a download-completion callback.

As an Amazon Associate I earn from qualifying purchases.

File uploads are a separate feature: Puppeteer documents locating a file input and calling ElementHandle.uploadFile. Upload support should not be confused with download handling.

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

Choose a download policy and destination

The DownloadBehavior API has four policies. For allow and allowAndName, provide downloadPath. The API reference specifies that allowAndName names downloaded files using their download GUIDs, rather than the usual filename. DownloadBehavior reference

Policy Effect Path requirement
deny Block downloads. No path requirement stated.
allow Allow downloads using the browser’s normal naming behavior. downloadPath required.
allowAndName Allow downloads and name files using their download GUIDs. downloadPath required.
default Leave behavior to the browser’s default. No path requirement stated.

These policy names and path requirements are from Puppeteer’s current API reference. Check the reference for the version and browser setup used by your project; the documentation does not establish identical behavior across every browser or protocol.

Set behavior when creating a browser context

The current BrowserContextOptions reference includes an optional downloadBehavior field. If it is unset, the browser’s default behavior applies. BrowserContextOptions reference The example below shows the documented option shape for allowing downloads into a chosen directory:

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
import puppeteer from 'puppeteer';

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

const page = await context.newPage();
await page.goto('https://example.com');
// Trigger the download using the page's UI or application flow.

await browser.close();

Replace the example path with a directory that exists and is writable in the environment running the browser. This configures where the browser may save a page-triggered download; it does not make Puppeteer wait for completion or return the file. The example uses the current reference’s context-options shape; confirm it against your installed Puppeteer version.

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

Set behavior when connecting to a browser

ConnectOptions also includes downloadBehavior to set behavior for the context. ConnectOptions reference This is relevant when your code connects to an existing browser rather than launching one. The exact execution details depend on the browser and connection setup, so do not assume the option guarantees a universal download workflow.

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

Wait for and verify a downloaded file

Puppeteer’s Files guide does not document a built-in download-completion event or file object. A practical implementation pattern is to let the browser write into the configured directory, then use filesystem facilities in your runtime to check that the expected file exists and is complete. That check is your own application logic, not a Puppeteer download API.

  • Use a dedicated, writable download directory for the run so unrelated files do not look like results.
  • Trigger the download through the page’s actual UI or application flow after setting the policy.
  • Inspect the directory with your runtime’s filesystem APIs and verify the expected name, size, or contents according to your application.
  • For GUID-based naming with allowAndName, do not expect the site’s suggested filename; map the resulting file to the intended download using your own workflow.

The documentation cited here does not specify a cross-browser completion signal, timeout strategy, or universal way to map a GUID-named file back to a page action. Those details must be implemented and validated for the browser and runtime you use.

Keep browser installation downloads separate

Installing Puppeteer’s browser is not the same operation as downloading a file from a page. The puppeteer package automatically downloads a compatible Chrome for Testing binary during installation. Starting with Puppeteer v19.0.0, the documented default browser cache is $HOME/.cache/puppeteer. The puppeteer-core package does not download Chrome and is intended for cases where you connect to a remote browser or manage browser installation yourself. See the Puppeteer configuration guide.

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

Troubleshoot common download problems

  • The browser blocks the file: Check the context’s download policy. If downloads should be permitted, use allow or allowAndName and provide downloadPath.
  • No file appears in the chosen directory: Confirm the path exists and is writable by the browser process, and verify that the page action actually triggered a download.
  • The saved filename is unexpected: With allowAndName, filenames are based on download GUIDs. Choose allow if you need the browser’s normal naming behavior.
  • Your code cannot tell when the file is ready: The Files guide does not promise a Puppeteer completion callback. Add a runtime-level filesystem check suited to your environment rather than treating the context option as a wait mechanism.
  • The option is missing or behaves differently: Check the installed Puppeteer version and whether you are setting context options at creation or connecting options when attaching to a browser. The cited BrowserContextOptions page is the next reference, while the current API pages identify Puppeteer 25.12.0.
  • You expected Puppeteer to install Chrome: Check whether your project uses puppeteer or puppeteer-core; the latter does not download the browser.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your task is to capture a webpage rather than save a file the page generated, ScreenshotNeo provides a website screenshot API. One GET request returns an image or PDF, without requiring you to configure Puppeteer for that capture. It removes cookie banners, popups and chat widgets before the shot; bot checks, blank pages and failed loads are never billed; an MCP server lets AI agents take screenshots; and 1,000 screenshots a month are free with no card, with paid plans starting at $5 for 3,000.

For a screenshot, not a page-generated download:

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. Sign up for 1,000 free screenshots a month, with no card required.

Frequently Asked Questions

Does Puppeteer provide a file-download API?

Its Files guide says it currently does not offer a way to handle file downloads programmatically. The documented download behavior configures the browser context, not a file object or completion callback.

Is downloading Chrome during installation the same as downloading a page’s file?

No. The browser package installation downloads an executable; a page-triggered download is a separate browser-context operation.

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.