跳到主要內容
版本:23.11.1

檔案

目前,Puppeteer 沒有提供以程式化的方式處理檔案下載的方法。若要上傳檔案,您需要找到一個檔案輸入元素並呼叫 ElementHandle.uploadFile

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