-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Downloading dynamically generated file fails when Cypress does not detect page load #14789
Comments
Can you provide an example, html/js of a download where the page load is causing Cypress to fail? It'd be helpful for looking into the issue or creating a workaround. Our example recipes has an example with using a form |
Looking at the testing-dom_download example it's just using a simple GET request. CFML Example <cfheader name="Content-disposition" value="attachment;filename=#somefile#">
<cfcontent file="#somefile#" type="application/pdf"> PHP Example $filePath="file path here";
$filename="file name here";
header('Content-type:application/pdf');
header('Content-disposition: inline; filename="'.$filename.'"');
header('content-Transfer-Encoding:binary');
header('Accept-Ranges:bytes');
@ readfile($filePath); Node Example app.post('/url/to/hit', function(req, res, next) {
var stream = fs.readStream('/location/of/pdf');
var filename = "WhateverFilenameYouWant.pdf";
// Be careful of special characters
filename = encodeURIComponent(filename);
// Ideally this should strip them
res.setHeader('Content-disposition', 'inline; filename="' + filename + '"');
res.setHeader('Content-type', 'application/pdf');
stream.pipe(res);
}); I'll see if I can hack up a working example in PHP. I'm assuming these all use the same technique. |
Hi @jennifer-shehane |
I get the same issue with 6.5.0 and a file download via XHR (POST) and not a simple GET. |
Can anyone provide a reproducible example that we can run completely? An HTML/JS file or a repo would be ideal. That was we can investigate. |
I get the same issue with 6.6.0 & 5.6.0. |
@syafiqhadzir Can anyone provide a reproducible example that we can run completely? An HTML/JS file or a repo would be ideal. That was we can investigate. |
I cobbled this example together: https://github.com/jimpriest/cfml-cypress-download This will spin up a Docker container running CFML and will dynamically deliver a file for download. You can see where it does download the file into the downloads folder but then Cypress hangs and never gets to the assertion/validation step and eventually times out... (page load) --waiting for new page to load-- See readme for info - simple link to a dynamically delivered file which fails in Cypress. |
Hi @jimpriest , you can find a workaround here - #14857 |
Yay. Been away from Cypress for a bit but this workaround in #14857 seems to work for me. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
Current behavior
Was playing around with the new download feature in 6.3.0 but that functionality seems to be targeted at simply downloading a file from a link.
I am dynamically generating a file on the server (via ColdFusion) and serving it through the browser. These are mainly reports. A user selects several 'filter' drop downs to select what data they want and then they click submit to generate a report. ColdFusion processes this on the backend and then serves the file through the browser.
See: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-c/cfcontent.html
So in 6.3.0 I submit my form, the file is downloaded to cypress/downloads (yay) but the actual Cypress test fails while waiting for a page load which never happens.
This is also similar to #8619, #7083
Searching it seems there have been quite a few issues opened for some way to stop or intercept a page load.
Desired behavior
Once the file is downloaded have Cypress stop waiting for page load.
Versions
Cypress 6.3.0
The text was updated successfully, but these errors were encountered: