Puppeteer is failing to upload a file with TypeError: Failed to fetch

Viewed 898

I've followed the documentation and examples on how to use Puppeteer's uploadFile() method.

However, I keep receiving this error message Evaluation failed: TypeError: Failed to fetch

I can't figure out why I can't automate this upload. I have a file saved in my repo that I am trying to upload.

Here is a snippet of uploadFile() code.

    await page.waitForSelector('input[type="file"]');


    const fileInput = await page.$('input[type="file"]');

    const filePath = 'path-to-my-file';

    await fileInput.uploadFile(filePath);

Any pointers on where I should look?

* "Solution" * Looks like Puppeteer version 2.1.1 may have issues indicated by this GitHub ticket. https://github.com/puppeteer/puppeteer/issues/5503 There are several other open tickets related to the same issue if you check the repo (as of 03/23/20).

In that ticket, the user downgraded to 2.0.0 and the attachment feature works.

1 Answers
Related