0
0
Cypresstesting~10 mins

File download verification in Cypress - Interactive Code Practice

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

Complete the code to check if the file download link exists.

Cypress
cy.get('a.download-link').[1]()
Drag options to blanks, or click blank then click option'
Ashould('exist')
Bclick()
Ctype()
Dcontains()
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of should('exist') causes the test to try clicking before verifying presence.
Using type() is invalid for links.
Using contains() checks text but does not assert existence.
2fill in blank
medium

Complete the code to trigger the file download by clicking the link.

Cypress
cy.get('a.download-link').[1]()
Drag options to blanks, or click blank then click option'
Ashould('exist')
Bclick
Cclick()
Dtrigger('download')
Attempts:
3 left
💡 Hint
Common Mistakes
Using click without parentheses does not execute the command.
Using should('exist') only checks presence, does not trigger download.
trigger('download') is not a valid Cypress command.
3fill in blank
hard

Fix the error in the code to verify the downloaded file exists in the downloads folder.

Cypress
cy.readFile('cypress/downloads/[1]').should('exist')
Drag options to blanks, or click blank then click option'
AdownloadedFile
BdownloadedFile.pdf
CdownloadedFile.docx
DdownloadedFile.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the file extension causes the file not to be found.
Using a wrong file name causes the test to fail.
4fill in blank
hard

Fill both blanks to check the downloaded file size is greater than zero.

Cypress
cy.readFile('cypress/downloads/[1]').then((file) => {
  expect(file.length).[2](0)
})
Drag options to blanks, or click blank then click option'
AdownloadedFile.pdf
Bto.be.greaterThan
Cto.equal
DdownloadedFile.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Using to.equal instead of to.be.greaterThan will fail if file length is not exactly zero.
Using wrong file name causes file not found error.
5fill in blank
hard

Fill all three blanks to verify the downloaded file content includes the expected text.

Cypress
cy.readFile('cypress/downloads/[1]').should('[2]', 'Sample Text').then((content) => {
  expect(content).to.[3]('Sample Text')
})
Drag options to blanks, or click blank then click option'
AdownloadedFile.pdf
BdownloadedFile.txt
Ccontain
Dinclude
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong file name causes file not found error.
Using to.include instead of to.contain causes assertion error.