[BUG] waitForEvent filechooser timeout
See original GitHub issue- Playwright Version: 1.28.1 / 1.27.1
- Operating System: Windows 10
- Node.js version: 18.12.1 / 7.13.0
- Browser: All expect Firefox, no one in 1.27.1/7.13.0 this is 2 different setups
Code Snippet
import { test, expect } from "@playwright/test";
import dotenv from "dotenv";
dotenv.config();
// ENV
let LoginNew = process.env.LOGIN_NEW || "";
let PwdNew = process.env.PASS_NEW || "";
// ENV
test("censored", async ({ page }) => {
await page.goto(`${URL}login`);
await page
.locator(
'//*[@id="censored"]/div/div/div/div/div/div/form/div[3]/div[2]/div/div'
)
.click();
await page.getByText("Français").nth(1).click();
await page.locator('input[name="email"]').type(LoginNew);
await page.locator('input[name="password"]').type(PwdNew);
await page.getByRole("button", { name: "censored" }).click();
await expect(page).toHaveURL(`${URL}`);
await page.locator(".SkipTutorial").click();
await page.getByTestId("MenuIcon").click();
await page.getByRole("link", { name: "censored" }).click();
await page.locator(".leftContent").click();
await expect(page).toHaveURL(`${URL}`);
await page.getByRole("link", { name: "censored" }).click();
await expect(page).toHaveURL(`${URL}censored`);
await page.getByRole("button", { name: "censored" }).click();
await page.waitForTimeout(1000);
await page.mouse.move(500, 150);
await page.mouse.down();
await page.mouse.move(300, 150);
await page.waitForTimeout(500);
await page.mouse.move(0, 150);
await page.mouse.up();
await page.locator(".startBtn").click();
const [fileChooser] = await Promise.all([
page.waitForEvent("filechooser"),
await page.getByRole("button", { name: "censored" }).click(),
]);
if (await page.locator("//div[@role='dialog']").isVisible()) {
page.click("(//button[@type='button'])[2]");
}
const filesUp = [
"./divers/censored.png",
"./divers/censored2.jpg",
"./divers/censored3.jpg",
];
let rdmfilesUp = filesUp[Math.floor(Math.random() * filesUp.length)];
await fileChooser.setFiles(rdmfilesUp);
await page.getByRole("button", { name: "censored" }).click();
await page.getByRole("button", { name: "censored" }).click();
});
This test is working fine with debug mode, but when I run this in headless, it keep crashing except on Firefox (I guess its due to the fact that I put permissions.default.microphone: 1
& permissions.default.camera: 1
in playwright.config.ts) (I have permissions: ["camera","microphone"]
on Chrome too), here is the CLI logs:
! This test is for a React Native app !
Here is the trace:
I have the feeling that it is because of this modal that it timeout/crashes, this modal appears because there are no permissions on the camera
Issue Analytics
- State:
- Created 10 months ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Problem with fileChooser. File chooser handling does not ...
I solved this by running in Chromium. It should work if you remove the executablePath parameter from the config. Share. Share a link...
Read more >Debugging a failed Promise to Upload File - Robot Framework
This fails at Wait For ${promise} with the message TimeoutError: fileChooser.setFiles: elementHandle.setInputFiles: Timeout 10000ms exceeded ...
Read more >FileChooser | Playwright - CukeTest
FileChooser ] objects are dispatched by the page in the ... timeout <number> Maximum time in milliseconds, defaults to 30 seconds, pass 0...
Read more >Playwright Upload File Without Input Element - YouTube
In several cases, you will find that the input element is hidden or not directly linked with an element that triggers the file...
Read more >https://raw.githubusercontent.com/microsoft/playwr...
An example of handling a timeout error: ```js try { await page. ... Playwright can respond to it via setting the input files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this should be the following
otherwise the async flow is not guaranteed. You want to have first let the filechooser listener attach and then click, when having an await there, it first does the click and race then most likely.
this should also be
(missing await)
Most likely this already makes your script work when you apply these two suggestions. this is unrelated to the permission issue tho.
Let us know if this helps!
I already have theses perms here (Pastebin)
Well, since I’ve written this several times, the browsers timeout all on the same line (EXCEPT FIREFOX) : ‘filechooser’, the technology used is native as simple as that, here it is : https://developer.mozilla.org/fr/docs/Web/API/MediaDevices/getUserMedia
I’ll write a summary for all of you BROWSERS :
Firefox: ✅ working Chromium : ❗ NOT WORKING Google Chrome : ❗ NOT WORKING MS Edge : ❗ NOT WORKING Webkit : ❗ NOT WORKING
Guys it doesn’t seem very complicated to understand