Cypress · Junior · Question 65 of 75
How do you test a file upload in Cypress?
- 1
cy.get('input[type=file]').selectFile('photo.png') - 2
cy.upload('photo.png') - 3
cy.get('input[type=file]').type('photo.png')
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' }.