question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File upload doesn't work

See original GitHub issue

Steps to recreate:

  • Run following code:
const playwright = require("playwright");

(async () => {
  const browser = await playwright["chromium"].launch({ headless: false });
  const context = await browser.newContext();
  await context.newPage("https://cgi-lib.berkeley.edu/ex/fup.html");
})();
  • Click on “Choose File”

Expectation: A file chooser dialog will appear Result: No dialog appears

This bug is causing file uploads to not work.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
arjunattamcommented, Jan 30, 2020

Thanks @VikramTiwari. Yes, that is a limitation. It is possible to intercept the file chooser dialog. Would that help?

page.on('filechooser', async ({ element, multiple }) => {
    console.log('intercepting filechooser');
    await element.setInputFiles('example.png');
});
7reactions
arjunattamcommented, Jan 30, 2020

Thanks @VikramTiwari. If you want to upload files, you can use the setInputFiles API on ElementHandle (docs). Example snippet below.

const playwright = require("playwright");

(async () => {
    const browser = await playwright["chromium"].launch({ headless: false });
    const context = await browser.newContext();
    const page = await context.newPage("https://cgi-lib.berkeley.edu/ex/fup.html");

    const handle = await page.$('input[type="file"]');
    await handle.setInputFiles('example.png');
})();

Read more comments on GitHub >

github_iconTop Results From Across the Web

File Upload not working, how do i fix this? - Microsoft Community
1) Reset the browsers in Windows Settings > Apps & Features > Browser > Advanced Options > Reset and Repair to see if...
Read more >
I Can't Upload My Files - Strikingly Help Center
If you're having trouble uploading your files, follow the troubleshooting steps. Step 1: Check your file The file size should be less...
Read more >
Fix Files Won't Upload To Any Web Page or Email ... - YouTube
Unable to Upload Files to Any Website or email as attachment on Google Chrome or Microsoft Edge Error Not RespondingStep 1) Clear Browsing ......
Read more >
I am Having Trouble Uploading an Assignment File.
This happens when you are uploading a large file or have a slow connection. Audio, video, and media rich PowerPoint presentations can result...
Read more >
Troubleshooting file upload problems - UK Copyright Service
Make sure the file is not corrupted. · Copy the file to your home/desktop folder and upload from there. · Don't upload folders...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found