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

File download issue, after that page visit times out #15161

Closed
kbaala88 opened this issue Feb 19, 2021 · 19 comments
Closed

File download issue, after that page visit times out #15161

kbaala88 opened this issue Feb 19, 2021 · 19 comments
Labels
stage: needs information Not enough info to reproduce the issue stale no activity on this issue for a long period

Comments

@kbaala88
Copy link

Hi,

Currently tried on Cypress 6.3.0, 6.4.0, 6.5.0 & older versions as well. In our application under test, we see that cypress gets stuck and couldn't proceed to next page stating that it is waiting for a load event that would never occur. Tried multiple workarounds , but couldnt resolve. Same behavior in chrome & electron browsers as well.

After debugging, found that cypress thrown below error that we could see from browser console. This issue is a blocker to us and any help on this issue would be of a great help.

<script type='text/javascript'> document.domain = '***.org'; var Cypress = window.Cypress = parent.Cypress; if (!Cypress) { throw new Error('Something went terribly wrong and we cannot proceed. We expected to find the global Cypress in the parent window but it is missing!. This should never happen and likely is a bug. Please open an issue!'); }; Cypress.action('app:window:before:load', window); </script>

@jennifer-shehane
Copy link
Member

This script is added to every application run within Cypress. Is this error being thrown in the console? Can you give a screenshot of the console?

Can you provide a reproducible example? Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Feb 19, 2021
@kbaala88
Copy link
Author

kbaala88 commented Feb 19, 2021

@jennifer-shehane : Thanks for the quick response. Due to restrictions, we couldn't share the code. However, below or the snapshots.

Browser network response snapshot showing the error while cypress is stuck:
1

Cypress browser window in right corner displaying the loading icon (forever):

2

Left cypress window showing, page load (forever)[NOTE: Actually application is loaded fully, but cypress waits thinking for a page load that will never load]. Couldn't workaround this and stuck.

3

@bahmutov
Copy link
Contributor

I am not sure I understand - is the test failing? I think the previous page is triggering file download, which breaks the next page's visit. You can mock the redirect and other server responses (even the document), see examples in https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/stubbing-spying__intercept#stubbing-application-requests-using-cyintercept

But really I do not understand what the test is meant to do, how it is written, what the app is doing, and what is going wrong or right here

@kbaala88
Copy link
Author

@bahmutov : Yes, the test stuck in the very 2nd page of the flow. & You are right, the previous page is triggering a file download, which is breaking the next page's visit.
Our application is single page architecture application i.e., all the pages in the application will be having the same url. Is it a known issue that, if the page triggers a file download will break next page's visit?

Also, couldnt find an example to mockthe server responses ( the document). Please help with one. Thanks!!!

@bahmutov
Copy link
Contributor

If you can explain how you download the file there, we could advise how to avoid the stuck test. We have a bunch of file download examples in https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/testing-dom__download recipe that might help

@kbaala88
Copy link
Author

@bahmutov : It is about a jnlp file download and step is like , click "OK" button , JNLP file download starts and application moves to next page. When cypress gets to next page, it is getting stuck and couldn't proceed though the controls are accessible.

@bahmutov
Copy link
Contributor

Can you create small repo reproducing the file download? Or fork https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/testing-dom__download and set up the file download the way it is done in your application so that we can investigate?

@bahmutov bahmutov changed the title var Cypress = window.Cypress = parent.Cypress; if (!Cypress) { throw new Error('Something went terribly wrong and we cannot proceed. We expected to find the global Cypress in the parent window but it is missing!. This should never happen and likely is a bug. Please open an issue!') File download issue, after that page visit times out Feb 23, 2021
@kbaala88
Copy link
Author

kbaala88 commented Feb 23, 2021

@bahmutov : Due to project limitations, couldn't share the code. Cypress step is to click OK and proceed to next page and perform further steps. In the 2nd page, application loaded successfully but cypress stuck and it thinks something yet to be loaded which will never load. Please let know if we can overwrite or skip the waiting for new page to load step and proceed?
Please note that all the pages in our application has the same URL.
3

@bahmutov
Copy link
Contributor

@kbaala88 all I am asking is to see how the download is triggered because obviously, it is not the same as in our recipe. When you trigger the download the browser tries to display that file probably (just like a like to PDF sometimes downloads the file, but sometimes is displayed in the browser). When the browser tries to display the file - guess what, it can no longer be controlled by Cypress, since it switched to the file view mode.

This is NOT a problem with the next page loading or waiting. This is a problem with the file taking over the browser tab, blocking the rest of the test execution.

Thus if we understand how the file download event is coded in your application, we can suggest a workaround. Without it, there are only our examples we are showing in the recipe that we can suggest.

@kbaala88
Copy link
Author

@bahmutov : Thanks for the quick responses. It is the file displayed in the browser and the file type is .jnlp

@bahmutov
Copy link
Contributor

bahmutov commented Feb 23, 2021 via email

@kbaala88
Copy link
Author

Unfortunately cudnt share the code! Below wud be the sample looks like:
document.location.href = 'jnlp:$(url)'

location:Location;
onfullscreenchange:((this: Document, ev:Event) => any) | null;

@bahmutov
Copy link
Contributor

Take a look at cypress-io/cypress-example-recipes#651
I am using CSV file, but I think the principle is the same

@kbaala88
Copy link
Author

Thanks much for the quick responses. Is it working for the CSV file?
Applied the same to .jnlp file and still the issue persists unfortunately .;(

@bahmutov
Copy link
Contributor

bahmutov commented Feb 23, 2021 via email

@kbaala88
Copy link
Author

@bahmutov : There is a call planned with cypress support team on this tomorrow. Please see if you can join or i shall keep posted on this.

@ajgray2017
Copy link

ajgray2017 commented Apr 24, 2021

Updates on this? I have a similar issue, on the latest version of Cypress, after clicking and downloading a test txt file, (Mine from a presigned url) the page waits for a new load and fails after a timeout. I am following the code presented by the cypress recipe.

@kbaala88
@bahmutov

#14857 (comment)
this unblocked me

@bahmutov
Copy link
Contributor

bahmutov commented Apr 24, 2021 via email

@cypress-app-bot
Copy link
Collaborator

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.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs information Not enough info to reproduce the issue stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

5 participants