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.

[BUG] Filechooser seems to fail for me

See original GitHub issue

Hi, I was trying upload few files using playwright, but it seems to fail for me. I assume I might be doing something wrong.

Details: Playwright Version: 1.6.2 Operating System: Windows 7 Node.js version: 12.18.0 Browser: Firefox

Code:

const {
  firefox
} = require('playwright');
const path = require('path');

// Add youtube email & password
let email = 'xxxxxxx@email.com'
let pass = 'xxxxxxxxxxxx'
let filePath = path.join(__dirname, 'xxxxxxxxxxx.mp4')

async function begin(){
   const browser = await firefox.launch({
        headless: false
      })
     const context = await browser.newContext()
 
    const page = await context.newPage()
    await page.goto('https://www.youtube.com/upload')

    await page.fill('input[type="email"]', email);
    await page.click('text=Next');
    await page.fill('input[type="password"]', pass);
    await page.click('text=Next');
    await page.waitForLoadState();
 await page.on('filechooser', async (fileChooser) => {
     console.log("filechooser called")
      await fileChooser.setFiles(filePath)
  })

  // Button that initiates filechooser event
  await page.click('text=Select files');

}

begin()

Log:

     pw:api <= page.click succeeded +2ms
    filechooser called
      pw:api => elementHandle.setInputFiles started +20ms
      pw:api   navigated to "https://studio.youtube.com/ytscframe" [] +172ms
      pw:api   "domcontentloaded" event fired [] +2ms
      pw:api   "networkidle" event fired [] +498ms
      pw:api <= elementHandle.setInputFiles failed +691ms
     (node:15396) UnhandledPromiseRejectionWarning: Error: elementHandle.setInputFiles: Evaluation failed: NetworkError when attempting to fetch resource.
    
    Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs.
        at checkException (c:\Users\Nawaz\node_modules\playwright\lib\firefox\ffExecutionContext.js:86:15)
        at FFExecutionContext.evaluateWithArguments (c:\Users\Nawaz\node_modules\playwright\lib\firefox\ffExecutionContext.js:49:9)
        at async evaluateExpression (c:\Users\Nawaz\node_modules\playwright\lib\javascript.js:164:16)
        at async FrameManager.waitForSignalsCreatedBy (c:\Users\Nawaz\node_modules\playwright\lib\frames.js:90:24)
        at async FrameExecutionContext.evaluateInternal (c:\Users\Nawaz\node_modules\playwright\lib\dom.js:36:16)
        at async FFPage.setInputFiles (c:\Users\Nawaz\node_modules\playwright\lib\firefox\ffPage.js:380:9)
        at async c:\Users\Nawaz\node_modules\playwright\lib\dom.js:440:13
        at async FrameManager.waitForSignalsCreatedBy (c:\Users\Nawaz\node_modules\playwright\lib\frames.js:90:24)
        at async ElementHandle._setInputFiles (c:\Users\Nawaz\node_modules\playwright\lib\dom.js:438:9)
        at async c:\Users\Nawaz\node_modules\playwright\lib\dom.js:421:28
      -- ASYNC --
        at ElementHandle.setInputFiles (c:\Users\Nawaz\node_modules\playwright\lib\helper.js:79:23)
        at FileChooser.setFiles (c:\Users\Nawaz\node_modules\playwright\lib\fileChooser.js:35:36)
        at FileChooser.setFiles (c:\Users\Nawaz\node_modules\playwright\lib\helper.js:80:31)
        at Page.<anonymous> (c:\Users\Nawaz\Desktop\playwright\login.js:51:25)
        at Page.emit (events.js:315:20)
        at Page._onFileChooserOpened (c:\Users\Nawaz\node_modules\playwright\lib\page.js:100:14)
    (node:15396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:15396) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
      pw:api   "load" event fired [] +9s

Link: https://www.youtube.com/upload

Page Screenshot:

-2020-dec-11-003

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
aslushnikovcommented, Dec 15, 2020

@fawazahmed0 the https://github.com/microsoft/playwright/issues/3496 should be fixed now - so at the very least, Chromium should work fine for this usecase. Could you please verify this?

1reaction
viraxslotcommented, Dec 14, 2020

@fawazahmed0 begin() function is async, please use await begin() to call it. I suppose it should help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - FileChooser dialog action error - Stack Overflow
1 Answer 1 ... From my little research it seems to be a bug in the OS and not in JavaFX. Have a...
Read more >
GTK FileChooser causes crashes in several programs
I experienced this bug in 1.01 AppImage of Inkscape. Mike Nealy gives an explanation and workaround in a bug report here.
Read more >
Bug 691040 – selection is reported incorrectly in file chooser button
Run program. Press "Click Me" to bring up a dialog with an FCB. Click the FCB, select "Other". Click on a folder in...
Read more >
45135 – GTK Filechooser cannot select a folder
Probably more general problem of GTK Filechooser, but seen only when adding docs folder to java platform as javadoc location.
Read more >
JDK-4225375 JFileChooser hangs when jaz drive exists - Bug ID
When the stale drive did timeout, the JFileChooser dialog was displayed behind all other windows rather than coming to the front and so...
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