Support ability to visit non `text/html` content-type pages (aka - visit downloaded file page)
See original GitHub issueCurrent behavior:
I am trying to test a download action from a .ts
file using the attribute window.location.href
. It doesn’t matter what value I assign for the URL string, the test instruction fails claiming a timeout waiting for the request when the file actually has been downloaded in few seconds. For some unknown reason Cypress never can reach the URL.
Note: I am using a Genesis UI theme as my development code base.
These are the paths that I have tried aiming to get an Ok result from the Cypress test:
window.location.href = '/api/download/file_id';
window.location.href = '/#/api/download/file_id';
window.location.href = 'http://localhost:5000/api/download/file_id';
window.location.href = 'http://localhost:5000/#/api/download/file_id';
All of them fail. But if I try the first option as a normal user from the browser directly, the download works perfectly.
Note: During the Cypress test, I can see how the file is actually downloaded. The download action occurs.
Desired behavior:
All that I am expecting is to be able to test my download action from the Cypress test.
If I trigger the download button using something like:
cy.get('[data-cy=download-file]').click();
I expect to get a positive response from the test if the file was actually downloaded.
How to reproduce:
Note: It would be great if you can try this steps using a Genesis UI theme as the base application.
- Create a form template with a button pointing to the
.ts
method on the (click) parameter:(click)="downloadFile()"
Note: Include adata-cy
parameter as part of the button in the form:data-cy="download-file"
- Inside the
.ts
method use the instruction, ensuring to use a valid path:window.location.href = '/path/to/file/for/download';
- Write a Cypress test when you try to trigger the download button from the form. Something like:
cy.get('[data-cy=download-file]').click();
- You should get a timeout message similar to the one included as attached image.
Test code:
cy.get('[data-cy=download-file]').click();
Additional Info (images, stack traces, etc)
- Operating System: Mac OSX 10.13.2
- Cypress Version: 2.1.0
- Browser Version: Google Chrome 65.0.3325.181
Issue Analytics
- State:
- Created 5 years ago
- Reactions:31
- Comments:22 (2 by maintainers)
Top GitHub Comments
This is resolved when you disabling chrome web security. This can be done by adding following line into
cypress.json
Any news on this?