-
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
Don't wait for page load when clicking a download link #8089
Comments
What do you mean when saying 'nonexistent page'? What is the normal behavior of the browser, does it navigate to the document in the browser? This is likely a duplicate of one of the issues below.
|
Yes, thank you! It's similar to #1551 and #788 which I hadn't been able to find. The normal behavior is simply downloading a file, no page is visited. All I need to do is initiate a click without waiting for a page load. I tried |
There's currently no way to prevent the page load from happening within Cypress itself once the application under test has initiated a page load - so the tests won't continue until that new page fires its load event. This thread may be helpful for testing downloading a file - as this is not completely supported in Cypress yet. #949 |
@haleypearse |
@jennifer-shehane |
I also have the same issue @jennifer-shehane and I'm looking for a solution. Clicking on a button which triggers a file download is usually just triggering the browser to download the file without changing the actual page thus not emitting a load event. |
Hello @jennifer-shehane. I also have the same problem. Have you any solution to solve it? |
Hi @jennifer-shehane |
Hi @jennifer-shehane We have the same problem with download(( Is there any update on this matter? |
No, there is no workaround or way to prevent this behavior. You will have to avoid clicking the download button or use any of the workarounds in this thread: #949 until the feature for testing file download is released. |
Is there an ETA on expected release? Something in the span of 1Q 2021 or 2Q, etc.? |
It's on our current roadmap. We're hoping to spike into assessing the effort it would take to support soon. https://on.cypress.io/roadmap |
Great, thanks for the update! |
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 This means that if you had any code written to prevent the download prompt or to configure the download location (like in a 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. |
Hi, @jennifer-shehane |
@maaaariana You may be experiencing this issue: #14857 There seem to still be some cases where this page load timeout occurs clicking to download files, but not all cases so we need to narrow down why. If you can add your example there. Thanks! |
@jennifer-shehane Hi, Jennifer! Having the same issue here. |
@jennifer-shehane same problem here. |
Same issue here. Telling waiting for new page to load when clicking on a link to download a file.. |
Same issue here. In cypress UI this works with all browsers. (after clicking on element, a pdf is open in a new page) In headless electron everything is fine. But in headless chrome and edge i got "waiting for new page to load". |
@jennifer-shehane I am facing the same issue, "waiting for new page to load" while the download has been visibly finished. |
I am having the same issue - Page Load event timeout - after clicking on a file download link. |
+1 for this issue |
Same for me |
I also still encounter this issue. Expected a page to load, but there is no page switch. Just a file being downloaded. |
Same issue here. |
Anyone has an idea? My test fails, but it's actually not failing. |
same issue here |
I have the same or similar issue as well. |
Same here, when trying to test for Auth0 login flow - after redirect, the page loads, but the event is not triggered and test fails 🌚 |
Add this
|
Same problem. Like after click login button it just showing "waiting for new page to load" in auth page. Can't believe this bug existing more than year in Cypress side. |
I have the same problem. On my page I have a form that makes a POST request to the server. The server returns with these headers:
The I get the 60 second page timeout error, even though the file downloaded correctly and into the correct Cypress downloads folder. |
same issue for me, do we have to create a new issue ? |
@anthony-bernardo I solved that problem adding in my |
I got the same problem. My workaround was to add following script before clicking the download button:
The page is reloaded after 1s and the load event is captured by Cypress. |
It works for most of the runs, but changes content of the page so extra steps are required to navigate back to initial page state. We have button which, when clicked, initiates file download, and this download works fine, file is saved inside "cypress/download" folder. I would be great if finish of this this download will satisfy Cypress "wait for page load"... I wonder is someone found better workaround for this issue than mentioned above... |
i don't know why this works but it does work for me
i asked ChatGPT and it said this:
|
Thanks for this idea! I've tried to add "download" attribute, even "download='somefile.txt'", also I've added it manually to the tested VUE app code. Cypress is still "waiting for page to load"... However, when I empty href attribute with "el.attr('href', '')", Cypress says it downloads file from originall_url and saves it in "cypress/downloads" folder, and then enters wait intercepted with original url, but in fact file is not downloaded... I've also tried adding target attribute to the download link but this makes Cypress to disappear.... |
This doesn't seem to be a bug on Cypress' end, its just how the browsers treat anchor elements. As #8089 (comment) mentioned, adding a download attribute solves the issue by injecting it during runtime or just adding it as an actual attribute. This worked for me for Firefox but might be treated differently from e.g. chrome. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes. |
I found this and it helped me
|
This Works for me! 4/2/2024 |
Current behavior:
Clicking this download link works fine, but I can't stop cypress from waiting for a nonexistant page to load, which prevents the rest of the test from running.
Desired behavior:
Some way to disable waiting for a page to load.
The text was updated successfully, but these errors were encountered: