Complete the code to select the file input element for drag and drop upload.
cy.get('[1]')
The file input element for uploading files is selected using input[type='file'].
Complete the code to attach a file named 'example.png' for drag and drop upload.
cy.get('input[type=file]').attachFile('[1]')
The file example.png is the correct file to attach as per the instruction.
Fix the error in the code to simulate drag and drop file upload correctly.
cy.get('input[type=file]').trigger('[1]', { dataTransfer: { files: ['example.png'] } })
The drop event simulates dropping the file onto the input for drag and drop upload.
Fill both blanks to create a test that uploads 'sample.pdf' by drag and drop and verifies the file name is shown.
cy.get('input[type=file]').attachFile('[1]') cy.get('.file-name').should('[2]', 'sample.pdf')
have.text which requires exact match instead of contain.The file sample.pdf is attached, and the assertion checks if the element contains the file name.
Fill all three blanks to write a test that uploads 'photo.jpg' by drag and drop, triggers the drop event, and asserts the upload success message.
const fileName = '[1]' cy.get('input[type=file]').attachFile(fileName) cy.get('input[type=file]').trigger('[2]', { dataTransfer: { files: [fileName] } }) cy.get('.upload-message').should('[3]', 'Upload successful')
The test attaches photo.jpg, triggers the drop event to simulate drag and drop, and asserts the message contains 'Upload successful'.