Cloud Browser File Downloads

Beta Feature: Cloud Browser is currently in beta and available to staff members only.

Cloud Browser supports automatic file download handling through a custom CDP extension. When the browser triggers a file download (PDFs, images, spreadsheets, etc.), you can retrieve the downloaded files using special CDP commands.

How It Works

When a navigation or user action triggers a file download in the browser:

  1. The browser intercepts the download request
  2. The file is saved to a temporary directory on the remote browser
  3. Download events are emitted so you can track progress
  4. You can retrieve the file content using the ScrapiumBrowser.getDownloads command
Key Points
  • Files are returned as base64-encoded strings
  • Maximum download size is 25 MB per file
  • Downloads are automatically cleaned up when the session ends
  • Multiple file downloads are fully supported in a single session
  • Browser download popups and confirmations are automatically bypassed for seamless automation
Automation-Friendly: Cloud Browser automatically disables browser download protection mechanisms (such as multiple download confirmation popups) that would normally interrupt automation scripts. Your downloads will proceed without any user interaction required.

CDP Commands

Cloud Browser extends the standard CDP protocol with custom ScrapiumBrowser commands for file download handling:

Command Description
ScrapiumBrowser.getDownloads Retrieve all downloaded files as base64-encoded content. Optionally delete files after retrieval.
ScrapiumBrowser.getDownloadsMetadatas Get metadata (filename and size) for all downloaded files without retrieving content.

ScrapiumBrowser.getDownloads

Retrieves all files currently in the download directory, encoded as base64 strings. This command takes no parameters.

Response

ScrapiumBrowser.getDownloadsMetadatas

Retrieves metadata for all downloaded files without transferring the actual content. Useful for checking what files are available before downloading.

Response

Code Examples

Download a file after clicking a download button:

Monitoring Download Progress

Cloud Browser emits standard Chrome CDP events that you can listen to for tracking download progress:

Event Description
Browser.downloadWillBegin Fired when a download is about to start. Contains URL and suggested filename.
Browser.downloadProgress Fired periodically during download. Contains progress state and bytes received.

Listening to Download Events

Multiple File Downloads

Cloud Browser fully supports downloading multiple files in a single session. Unlike regular browsers that may prompt for confirmation when triggering multiple downloads, Cloud Browser automatically accepts all downloads without interruption.

Example: Downloading Multiple Files

Tip: When downloading multiple files, you can use getDownloadsMetadatas to check how many files are ready before retrieving them all with getDownloads.

Common Use Cases

PDF Downloads

Download PDFs generated by web applications, such as invoices, reports, or tickets that are created dynamically after form submission or authentication.

Export Files

Retrieve data exports (CSV, Excel, JSON) from dashboards and analytics platforms that require browser interaction to generate.

Generated Images

Download images that are generated on-demand, such as charts, QR codes, or dynamically created graphics.

Protected Documents

Access documents behind authentication or CAPTCHA protection that can only be downloaded through a real browser session.

Best Practices

Wait for Downloads to Complete

Always wait for the download to complete before calling getDownloads. You can either use a fixed timeout, listen for the Browser.downloadProgress event with state completed, or poll getDownloadsMetadatas until files appear.

Automatic Cleanup

Downloaded files are automatically cleaned up when the browser session ends (either when you close the CDP connection or when the session times out with auto_close=true). You don't need to manually delete files unless you want to clear downloads during a long-running session.

Check File Size First

For large files, call getDownloadsMetadatas first to check the file size. Remember that base64 encoding increases size by approximately 33%, so a 25 MB file will transfer as ~33 MB of base64 data.

Handle Download Failures

Downloads can fail or be canceled. Listen to the Browser.downloadProgress event and check for state: 'canceled' or state: 'failed' to handle errors gracefully.

Limitations

  • Maximum file size: 25 MB per file
  • Session-scoped: Downloads are only available during the session that triggered them
  • Auto-cleanup: All downloads are deleted when the browser session ends
  • Transfer overhead: Base64 encoding adds ~33% to transfer size

Summary