uploadFile doesn't work with puppeteer.connect
See original GitHub issueSteps to reproduce
Currently when used inputElement.uploadFile
via puppeteer.connect
, it uploads an empty file, as it doesn’t exist on host machine. I believe this is a DevTools limitation and there’s no possible workaround except uploading the file to remote puppeteer’s host.
What steps will reproduce the problem?
const page = await puppeteer.connect(/* ... */);
const input = await page.$('input[type="file"]');
await input.uploadFile('./this/will/upload/an/empty/file');
What is the expected result?
- uploaded files are serialised before sent to devtools instead of their file paths,
- or an error thrown saying this is not supported via
connect
.
What happens instead?
Puppeteer silently uploads an empty payload.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Puppeteer file-chooser upload not working - Stack Overflow
I try to upload a video on instagram using puppeteer with FileChooser: const selectBtn = await page.$x("selector.
Read more >Practical Puppeteer: How to upload a file programatically
Today I will share about how to upload file using Puppeteer. If you don't know about Puppeteer yet, here is the brief explanation....
Read more >How to perform FileUpload testing with Puppeteer - YouTube
In this video, we will discuss working with FileUpload in Puppeteer.In this video we will discuss Working with XPath in Puppeteer automation ...
Read more >Node.js Puppeteer FileChooser Upload Files & Images to ...
Watch next – [Popular Videos on the Channel] [ Login with Google Account using Javascript] ... [ Uploading Files using Google Drive Api] ......
Read more >Puppeteer documentation - DevDocs
Puppeteer 7.1.0 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for the tip @mathiasbynens, it was really helpful!
For anyone facing issues uploading with puppeteer, here is the code I went with that finally worked
I hope this helps someone, instead of spending days working with and around puppeteer file upload.
However, @mathiasbynens do you have an idea of why the builtin calls (I see there is a CDP call in newer versions) in puppeteer don’t work? It would be nice to understand why that happened.
Thanks again for your help.
Since puppeteer verifies that files are present on its local file-system, then this breaks
connect
ed sessions in an unintuitive way. Versions <=3.0.0
handled this pretty well, but at the cost of sending more data over the network.Is it possible to make it more graceful? For instance, if it’s a
connect
ed session then do theDataTransfer
method, otherwise puppeteer can just pass the list of files over to chromium? Happy to do a PR, just don’t want to waste the time if it’s not viable.