0
0
Cypresstesting~10 mins

Why file testing validates uploads and downloads in Cypress - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select a file for upload in Cypress.

Cypress
cy.get('input[type="file"]').[1]('example.txt');
Drag options to blanks, or click blank then click option'
Aclick
BattachFile
Ctype
Dselect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'attachFile' does not upload a file.
Using 'type' on file input is invalid.
2fill in blank
medium

Complete the code to check if the uploaded file name is visible after upload.

Cypress
cy.get('.uploaded-file-name').should('[1]', 'example.txt');
Drag options to blanks, or click blank then click option'
Ahave.text
Bhave.value
Cinclude.text
Dcontain.text
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'contain.text' allows partial matches, which may not be strict enough.
Using 'have.value' is for input elements, not text display.
3fill in blank
hard

Fix the error in the code that verifies the downloaded file content.

Cypress
cy.readFile('cypress/downloads/[1]').should('include', 'Success');
Drag options to blanks, or click blank then click option'
Adownload.txt
Bdownloaded_file.txt
Cdownloaded.txt
Dfile.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using a file name that does not exist causes the test to fail.
Misspelling the file name leads to file not found errors.
4fill in blank
hard

Fill both blanks to upload a file and verify the upload success message.

Cypress
cy.get('input[type="file"]').[1]('report.pdf');
cy.get('.upload-status').should('[2]', 'Upload successful');
Drag options to blanks, or click blank then click option'
AattachFile
Bhave.text
Ccontain.text
Dclick
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'attachFile' does not upload the file.
Using 'have.text' for partial message matching may fail if message has extra spaces.
5fill in blank
hard

Fill all three blanks to read a downloaded file, check its size, and confirm content.

Cypress
cy.readFile('cypress/downloads/[1]').then((content) => {
  expect(content.length).to.be.[2](1000);
  expect(content).to.[3]('Download complete');
});
Drag options to blanks, or click blank then click option'
Adownload.txt
Babove
Cinclude
Dbelow
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'below' instead of 'above' causes the size check to fail.
Using 'equal' instead of 'include' misses partial content matching.