microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.65k stars 3.57k forks source link

[BUG] file chooser opens for real and doesn't trigger 'filechooser' event #12369

Closed targos closed 2 years ago

targos commented 2 years ago

Context:

Code Snippet

const { chromium, firefox } = require('@playwright/test');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://dev.nmrium.org/#/');
  await page.click('_react=ToolbarMenu >> nth=0');
  const [fileChooser] = await Promise.all([
    page.waitForEvent('filechooser'),
    page.click('_react=MenuItem[id = "importFile"]'),
  ]);
  console.log(fileChooser);
})();

Describe the bug

Instead of getting access to the file chooser from the filechooser event, the real system file chooser opens and the promise never resolves.

This only happens with Chromium. Firefox and Webkit work as expected.

mxschmitt commented 2 years ago

Your application uses react-dropzone which does internally use window.showOpenFilePicker see here.

This is not supported by Playwright yet, so merging into https://github.com/microsoft/playwright/issues/8850 for now (please upvote it there).

ShaneyWaris commented 2 years ago

Sir @mxschmitt , is there any way to choose a single folder with playwright instead of fileChooser?