Playwright · Junior · Question 30 of 75

How do you upload a file through an <input type="file">?

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.

Further reading

Problem with a question

Playwright · Junior · question 30

Test yourself

Take the Playwright · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz