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
cy.request(): Got a broken PDF file #3576
Comments
This same on Windows |
Yeah, this is reproducible from the code given above. |
Hi Same here. Is there any updates on this issue? Thanks, |
If anyone step into this river, the workaround in #2029 works (pdf). |
Hi there, |
I'm facing the same issue as well… any updates? |
I'm currently working on a fix proposal for this problem. The changes to cypress core would be:
I finished the implementation of the fix itself and ensured that it is working locally. Even though, I still need to write tests before creating 2 proposal PRs to cypress-io/cypress and cypress-io/request repositories. After the fix proposal, a working example would be: /// <reference types="Cypress" />
context('Download Pdf', () => {
it('Download Pdf', () => {
const pdfUrl = 'http://www.pdf995.com/samples/pdf.pdf';
// ADDED: "encodeBodyToBase64: true"
cy.request({ url: pdfUrl, gzip: false, encodeBodyToBase64: true }).then(
(response) => {
const fileName = 'test';
const filePath = 'temp/' + fileName + '.pdf';
cy.writeFile(filePath, response.body, {
encoding: 'binary',
decodeContentFromBase64: true, // ADDED
});
}
);
});
}); I.e: setting the flag |
The code for this is done in cypress-io/cypress#7382, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
When I tried to use
cy.request()
API to get content of PDF file, I end up with broken file content.Example of spec file:
As a result, I have got PDF file with blank pages:
test.pdf
Which is not really what I try to download:
http://www.pdf995.com/samples/pdf.pdf
Desired behavior:
I want to get exactly the same file that I would get if use browser to download it.
Steps to reproduce: (app code and test code)
examples
cypress/integration/sample/download-pdf.spec.js
file and put there a snippet fromCurrent behavior
section.temp
directory in the root directory of the projectdownload-pdf.spec.js
in GUItemp/test.pdf
file with source one: http://www.pdf995.com/samples/pdf.pdfVersions
Related Issues
The text was updated successfully, but these errors were encountered: