Challenge - 5 Problems
Drag and Drop File Upload Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Cypress drag and drop file upload test
What will be the test result when running this Cypress test code for drag and drop file upload?
Cypress
describe('Drag and Drop File Upload', () => { it('uploads a file via drag and drop', () => { cy.visit('/upload') cy.get('#dropzone').attachFile('example.pdf', { subjectType: 'drag-n-drop' }) cy.get('#uploaded-file-name').should('contain.text', 'example.pdf') }) })
Attempts:
2 left
💡 Hint
Check if the attachFile command is used correctly with drag-n-drop option.
✗ Incorrect
The test visits the upload page, attaches 'example.pdf' to the dropzone using drag-n-drop simulation, then verifies the uploaded file name is displayed. This is the correct usage of the attachFile plugin for drag and drop.
❓ locator
intermediate1:30remaining
Best locator for drag and drop file upload area
Which locator is the best practice to select the drag and drop upload area for testing accessibility and reliability?
Attempts:
2 left
💡 Hint
Consider accessibility attributes and stable selectors.
✗ Incorrect
Using an ARIA label like aria-label="File Upload Dropzone" ensures accessibility and a stable, descriptive locator that is less likely to change than classes or text content.
❓ assertion
advanced1:30remaining
Correct assertion for verifying file upload success message
Which assertion correctly verifies that the success message 'Upload complete' is visible after drag and drop file upload?
Attempts:
2 left
💡 Hint
Check for visibility and partial text match.
✗ Incorrect
Option D checks that the message element is visible and contains the expected text, which is the most reliable way to assert success messages in Cypress.
🔧 Debug
advanced2:00remaining
Identify the error in this drag and drop file upload test code
What error will this Cypress test code produce when running drag and drop file upload?
Cypress
cy.get('#dropzone').attachFile('test.png') cy.get('#uploaded-file').should('contain', 'test.png')
Attempts:
2 left
💡 Hint
Consider how attachFile works with drag and drop elements.
✗ Incorrect
When uploading files via drag and drop, attachFile must be called with { subjectType: 'drag-n-drop' } option. Omitting it causes the test to fail because the file is not attached correctly.
❓ framework
expert3:00remaining
Best practice for testing drag and drop file upload in Cypress with accessibility
Which approach best combines accessibility, reliability, and maintainability when testing drag and drop file upload in Cypress?
Attempts:
2 left
💡 Hint
Think about accessibility attributes and proper assertions.
✗ Incorrect
Option B uses an accessible locator with aria-label, correctly uses the drag-n-drop option, and asserts both visibility and text content, making it the best practice for maintainable and reliable tests.