dependent-tan•16mo ago
submit files
title, is there a straightforward way to submit files to a button that would trigger a file dialog?
1 Reply
Hi, thanks for asking!
It depends if you are using playwright or puppeteer, but it should be pretty similar.
Playwright
https://playwright.dev/docs/api/class-filechooser
Puppeteer
https://pptr.dev/api/puppeteer.page.waitforfilechooser
There is also this apify blog about uploading with puppeteer, you might also find some additional info here
https://blog.apify.com/how-to-download-and-upload-files-in-puppeteer/#:~:text=Uploading%20files%20with%20Puppeteer,-To%20perform%20an&text=uploadFile(...,with%20the%20file%20input%20element.
FileChooser | Playwright
FileChooser] objects are dispatched by the page in the [page.on('filechooser') event.
Page.waitForFileChooser() method | Puppeteer
This method is typically coupled with an action that triggers file choosing.
Apify Blog
How to download and upload files in Puppeteer
Learn to automate file downloads and uploads with Node.js