Cypress · Junior · Question 65 of 75

How do you test a file upload in Cypress?

Show the answer

Correct answer: cy.get('input[type=file]').selectFile('photo.png')

Explanation

.selectFile() can also simulate drag and drop with { action: 'drag-drop' }.

Further reading

Problem with a question

Cypress · Junior · question 65

Test yourself

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

Take this quiz