Set the path option in page.screenshot(). The value includes the directory and filename, for example 'screenshots/homepage.png'. A relative path is resolved from the Node.js process’s current working directory.
Set the screenshot path and filename
Pass the destination path as a string to page.screenshot():
As an Amazon Associate I earn from qualifying purchases.
await page.screenshot({ path: 'screenshots/homepage.png' });
The directory and filename belong in the same path value. In this example, Puppeteer writes the screenshot as homepage.png inside screenshots. The path option is documented in the ScreenshotOptions API, and the official screenshots guide shows the same pattern.
Choose a relative or absolute path
A relative path such as screenshots/homepage.png is resolved from the current working directory of the Node.js process—not automatically from the project root. If you run the script from a different directory, the relative destination changes accordingly. The API also accepts an absolute path; use one when you need to specify a fixed location independently of the launch directory. See ScreenshotOptions.
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Choose the file extension
Puppeteer infers the screenshot type from the filename extension. PNG is the documented default; use a matching extension such as .png or .jpeg to make the intended format clear. The supported format options are described in the ScreenshotOptions API.
Save an element screenshot to a path
Element screenshots accept the same path option. For example:
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
const element = await page.waitForSelector('div');
await element.screenshot({ path: 'output/div.png' });
ElementHandle.screenshot() scrolls the element into view if necessary. It throws if the element handle has detached from the DOM, so ensure the target still exists when capture runs. See the ElementHandle.screenshot() API.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsUse the screenshot bytes instead of writing a file
If you omit path, Puppeteer returns the screenshot data rather than saving it to disk. The normal return value is a Uint8Array; with base64 encoding enabled, the return value is a string. You can then write or process the data yourself. The return behavior is documented for Page.screenshot().
Rank #3
- Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Troubleshoot path problems
- The file is not where expected: Check the process’s current working directory and resolve the relative path from there. Use an absolute path if the destination must not depend on where the script is launched.
- No file appears: Confirm that you supplied
path. Without it, Puppeteer returns image data rather than writing the screenshot to a file. - The image format is unexpected: Check that the filename extension matches the format you intend; Puppeteer uses the extension to infer the screenshot type.
- An element capture fails: The element may have detached from the DOM. Wait for a current handle before calling
screenshot().
Or skip the browser setup
For a screenshot from an API call instead of Puppeteer code, ScreenshotNeo accepts a URL and returns an image or PDF. Its clean-shot options remove cookie banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed; its response headers report the page verdict and billing status. It also offers an MCP server for AI agents, and includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000.
cURL example (see the ScreenshotNeo documentation):
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Learn more at ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Quick Recap
Best Value
- [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
- 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
- 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
- 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
- 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
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.




