Does your company rely on browser automation or web scraping? We have a wild offer for our early customers! Read more →

How to Upload Files

Uploading files with a remote browser is not a trivial task, as the standard CDP method DOM.setFileInputFiles won't work on a remote filesystem.

Playwright

Playwright fully supports uploading files into a remote browser.

You can read more in their documentation or just take a look at the example below.

1
2
3
const inputElement = await page.locator('input#file')
// local path on your machine
await inputElement.setInputFiles('archive.zip');

Puppeteer

Unfortunately, Puppeteer's method element.uploadFile() supports only local files, so it won't work with remote browsers.

We're actively working on a solution, but meanwhile you can take a look at Playwright's implementation and use a similar technique leveraging the DataTransfer object with file content buffers.