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

[Docs]: Uploading file that does not exist does not produce any error #10053

Closed
2 tasks
Akxe opened this issue Apr 20, 2023 · 3 comments · Fixed by #10058
Closed
2 tasks

[Docs]: Uploading file that does not exist does not produce any error #10053

Akxe opened this issue Apr 20, 2023 · 3 comments · Fixed by #10058

Comments

@Akxe
Copy link

Akxe commented Apr 20, 2023

Bug expectation

I expected an error but did not get one. I did waste half a day on it (I am not mad, it is only really hard to tell if something went wrong...)

Bug behavior

  • Flaky
  • PDF

Minimal, reproducible example

import puppeteer from 'puppeteer';

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.setContent('<input type="file">')
  const inputHandle = await page.$('input[type=file]');
  await inputHandle.uploadFile('non-existing-src.jpg');
})();

Error string

no error

Puppeteer configuration

I am using `jest-pupeteer` with `.jest-puppeteerrc.json` file: 


{
  "launch": {
    "headless": true,
    "devtools": true,
    "exitOnPageError": false
  }
}

Puppeteer version

19.10.0

Node version

16.13.2

Package manager

npm

Package manager version

9.1.2

Operating system

Windows

@Akxe Akxe added the bug label Apr 20, 2023
@github-actions
Copy link

github-actions bot commented Apr 20, 2023

This issue has an outdated Puppeteer version: 19.10.0. Please verify your issue on the latest 19.10.1 version. Then update the form accordingly.


Analyzer run

@jrandolf-2
Copy link
Contributor

Sorry about this. We used to validate, but now we don't because the file comes from your remote environment which is not possible to validate. This sadly implies if your remote is your local, then we still can't validate because we can't detect that difference.

Under the hood, the input element doesn't validate what gets set there, it's assumed that you validated beforehand, so it's best to somehow validate the file before using your own framework (if it's local, then just use fs.existsSync) and then continuing on from there.

@Akxe
Copy link
Author

Akxe commented Apr 21, 2023

How about an update to the docs of uploadFile? Maybe a hint that the file is not validated could be helpful?

@jrandolf-2 jrandolf-2 reopened this Apr 21, 2023
@jrandolf-2 jrandolf-2 changed the title [Bug]: Uploading file that does not exist does not produce any error [Docs]: Uploading file that does not exist does not produce any error Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants