I’m trying to use page.setInputFiles() in Playwright to upload a file, but the input element I’m targeting is hidden.
My code looks like this:
await page.locator('//div/input[@class="xyz"]').setInputFiles('Upload_files/CSV Test file.csv');
However, Playwright fails to find the locator because the <input> element has the hidden attribute:
<input type="file" class="xyz" accept=".jpg,.jpeg,.png,.doc,.docx,.xlsx,.xls,.csv,.pdf" hidden>
What’s the right way to handle file uploads in Playwright when the file input is hidden or not directly visible in the DOM?