Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we intercept file download, and check whether it is valid download or not ? #5027

Closed
PrasadNutalapati opened this issue Aug 23, 2019 · 3 comments

Comments

@PrasadNutalapati
Copy link

PrasadNutalapati commented Aug 23, 2019

Currently we can only use cy.readFile() to check the file downloaded to the download folder. But with out downloading can we intercept and find out whether the link is providing a valid download file or not ?

a. User clicks on a link or button to open a file link.
b. Since browser is configured to download to downloads folder, it gets downloaded automatically.
c. We can use cy.readFile() to check the file size to verify whether it has been downloaded correctly or not.
d. Instead, we just need to check the file will be downloaded or not and assert by intercepting the file download in the network layer itself.

@brian-mann has suggested to some one to open a issue, but not sure whether it has been open or not. And whether it got implemented or not?

Versions

Cypress 3.4.1
Windows 10 enterprise, Chrome v76

@jennifer-shehane
Copy link
Member

Closing as part of this larger issue: #949

@jennifer-shehane
Copy link
Member

File download is now supported in Cypress 6.3.0.

You can now test file downloads in Cypress without the download prompt displaying. Any files downloaded while testing file downloads will be stored in the downloadsFolder which is set to cypress/downloads by default. The downloadsFolder will be deleted before each run unless trashAssetsBeforeRuns is set to false.

This means that if you had any code written to prevent the download prompt or to configure the download location (like in a before:browser:launch event handler), you can remove all of these workarounds.

Our file download recipe has been updated, so you can see some ways to test different types of files after they've been downloaded there.

If you're encountering any bugs while testing file downloads, please open a new issue.

@ssy21
Copy link

ssy21 commented Mar 12, 2021

@jennifer-shehane is there documentation anywhere on how to handle the download prompt? need to figure out how to press the save/cancel button on the download prompt dialog

@cypress-io cypress-io locked as resolved and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants