Skip to main content
Version: 23.2.0

文件

¥Files

目前,Puppeteer 不提供以编程方式处理文件下载的方法。对于上传文件,你需要找到一个文件输入元素并调用 ElementHandle.uploadFile

¥Currently, Puppeteer does not offer a way to handle file downloads in a programmatic way. For uploading files, you need to locate a file input element and call ElementHandle.uploadFile.

const fileElement = await page.waitForSelector('input[type=file]');
await fileElement.uploadFile(['./path-to-local-file']);