Screenshots, PDFs, Downloads, and Uploads
Screenshots
Browserbase enables screen view and full-screen screenshots using your desired browser automation framework with the following configuration:
Screenshot type | DPI | Format |
---|---|---|
Screen view (default) | 80 | jpeg |
Full-screen | 90 | jpeg |
Save a screenshot locally
A screenshot taken with Browserbase can be saved locally as a file:
PDFs
In addition to downloading files, you can also download web pages.
For playwright, you can use the page.pdf()
method to download a web page as a PDF.
After creating the session, we download the page in the A4 format and save it as webpage.pdf
.
Save a PDF locally
Here’s how to generate and save a PDF locally using Playwright:
Downloads
Unlike screenshots and PDFs which are saved locally, files downloaded during browser automation are stored in Browserbase’s cloud storage. These files must be retrieved using our API.
A typical use case for headless browsers is downloading files from
web pages. Our browsers are configured to sync any file you download to our
storage infrastructure. We add a Unix timestamp onto the end of the file name to avoid naming conflicts when downloading multiple files (e.g., sample.pdf
will become sample-1719265797164.pdf
).
Follow these steps to download files:
- Use the Sessions API to create a new session. You’ll need the session ID for when you connect.
- Configure your library’s downloads location.
- Perform the download action in your automation script.
- Retrieve the downloaded files using the Session Downloads API.
We sync the files in real-time; the size of your downloads might affect their
immediate availability through the /downloads
endpoint. The above code
provides a snippet to handle that use case.
Session Downloads API
Learn more about the available params and response fields
Uploads
You can easily upload files to websites using Playwright, Puppeteer, or Selenium.
Playwright
For Playwright, you can upload files directly from your local path.
-
You’ll need your file to be available where you’re running your Playwright code.
-
In this example, we’re using an image
logo.png
that’s available locally. -
Be sure to specify the path to your file by setting the input file.
For Puppeteer and Selenium, you’ll need to upload your files to our browser instance using our Uploads API.
-
Use the Sessions API to create a new session. You’ll need the session ID when you upload it.
-
Use the Session Uploads API to upload a file.
-
Connect to the browser and the file will be available in the
/tmp/.uploads
directory.
Was this page helpful?