Playwright · Junior · Question 30 of 75
How do you upload a file through an <input type="file">?
- 1
await page.upload('data/photo.png') - 2
await locator.setInputFiles('data/photo.png') - 3
await locator.fill('data/photo.png')
Show the answer
Correct answer: await locator.setInputFiles('data/photo.png')
Explanation
setInputFiles sets files on the input without opening the OS dialog. Passing an empty array clears the selection.