Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitForFileChooser() never resolves #5537

Closed
fredck opened this issue Mar 24, 2020 · 6 comments
Closed

waitForFileChooser() never resolves #5537

fredck opened this issue Mar 24, 2020 · 6 comments

Comments

@fredck
Copy link

fredck commented Mar 24, 2020

Steps to reproduce

// By calling waitForFileChooser(), the file chooser dialog doesn't show up.
// I'm not sure this is expected.
let fileChooser = page.waitForFileChooser();

// This works properly, because the file chooser shows up if I comment the above line.
page.click( '#fc-issue_body' );

// This promise never resolves.
fileChooser = await fileChooser;

// This line is never reached.
fileChooser.accept( [ 'test.png' ] );

Tell us about your environment:

  • Puppeteer version: 2.1.1 (built-in Chromium)
  • Platform / OS version: macOS 10.15.3
  • Node.js version:13.11.0

What is the expected result?

The file chooser should accept the provided file.

What happens instead?

waitForFileChooser() never resolves and the code gets blocked.

@mlovatonv
Copy link

I think you have to call both functions at the same time, like the documentation says https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#pagewaitforfilechooseroptions

const [fileChooser] = await Promise.all([
  page.waitForFileChooser(),
  page.click('#upload-file-button'), // some button that triggers file selection
]);
await fileChooser.accept(['/tmp/myfile.pdf']);

Also, this function seems to be more stable in puppeteer v2.0.0

@fredck
Copy link
Author

fredck commented Mar 26, 2020

I think you have to call both functions at the same time, like the documentation says https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#pagewaitforfilechooseroptions

I've tried that way and it doesn't work either. Same results.

Actually, I believe that the documentation is mistaken (that's why my implementation is different) because Promise.all() doesn't guarantee the order of execution of the promises in the array (maybe). Anyway, both implementation have the very same effect.

@mlovatonv
Copy link

mlovatonv commented Mar 26, 2020

I would recommend you trying with Chromium 79.0.3942.0 - Puppeteer v2.0.0 for now because I have seen some issues related to the fileChooser in the newer versions of pptr. This is because of the page.handleFileChooser removal (https://chromium.googlesource.com/chromium/src/+/41361e490363590c21250dfd94554f8200e041f1). I am not sure if this has been fixed, it wasn't working for me when I tried with pptr v2.1.0 and v2.1.1.

@fredck
Copy link
Author

fredck commented Mar 27, 2020

I would recommend you trying with Chromium 79.0.3942.0 - Puppeteer v2.0.0 for now

I've just tried it and I can confirm that things work well with v2.0.0. 

Thanks for the tip. Fingers crossed to have this issue fixed at some point.

fredck added a commit to ckeditor/github-writer that referenced this issue Mar 27, 2020
@mathiasbynens
Copy link
Member

#5654

@paullewis
Copy link
Contributor

This is fixed as of 532ae57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants