Skip to main content

Downloads

Kernel browsers run in fully sandboxed environments with writable filesystems. When your automation downloads a file, it’s saved inside the browser’s filesystem and can be retrieved using Kernel’s File I/O APIs.

Playwright

Playwright performs downloads via the browser itself, so there are a few steps:
  • Create a browser session
  • Configure browser download behavior using CDP
  • Perform the download
  • Retrieve the file from the browser’s filesystem
With behavior: 'default', downloads are saved to the browser’s default download directory. The CDP downloadProgress event includes a filePath field when the download completes, which tells you exactly where the file was saved. Use this path with Kernel’s File I/O APIs to retrieve the file.
The CDP downloadProgress event signals when the browser finishes writing a file, but there may be a brief delay before the file becomes available through Kernel’s File I/O APIs. This is especially true for larger downloads. We recommend polling listFiles to confirm the file exists before attempting to read it.
We recommend using the list files API to poll for file availability before calling read file, as shown in the examples above. This approach ensures reliable downloads, especially for larger files. You can also use listFiles to enumerate and save all downloads at the end of a session.

Stagehand v3

When using Stagehand with Kernel browsers, you need to configure the download behavior in the localBrowserLaunchOptions:
Here’s a complete example:

Browser Use

Browser Use handles downloads automatically when configured properly. Documentation for Browser Use downloads coming soon.

Uploads

Playwright’s setInputFiles() method allows you to upload files directly to file input elements. You can fetch a file from a URL and pass the buffer directly to setInputFiles().