I’m working on a Playwright test where I need to interact with a file input dialog. I’m using the setInputFiles
function to set the input file, but I’m encountering an issue where the file input dialog pops up and I can’t seem to dismiss it. This is causing my test to hang because the dialog remains open.
Here’s the relevant part of my test code:
await page.setInputFiles('input[data-testid="browseFileInput"]', 'path/to/myfile.nupkg');
When this line executes, I see the file input dialog appear, but there’s no clear way to close it. The DOM only contains a single line for the file input element:
<input id="browseFileInput" data-testid="browseFileInput" class="browseFileInput" type="file" accept=".nupkg">
There are no other buttons or elements that I can interact with to close the dialog.
I’m looking for a solution that allows me to set the input file without the dialog popping up, or if it does pop up, a way to programmatically close it so that the test can continue.