cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.01k stars 3.18k forks source link

Cypress Runner unexpectedly closes itself while navigating to a specific URL with a different origin #24084

Open TiManGames opened 2 years ago

TiManGames commented 2 years ago

Current behavior

If you navigate to the following url using cy.visit https://rom.my.universe.cdp.gigya.com, the test will close itself and Cypress will go back to the main specs screen. A test shouldn't behave like that, any error message would be in line.

Other people have tried to navigate to this URL on their end and got the same result.

I'm baffled as to why this is happening, but I noticed that after closing itself, the URL of the Runner itself changes to https://socialize.us1.gigya.com/__/#/specs

My suspicion: Somehow the redirection manages to change the topmost URL outside of Cypress' test iframe and thus exit the test. What can be done about this?

Desired behavior

Cypress should complete the navigation successfully, or at the very least, provide an error message.

Test code to reproduce

it('Should navigate to a different url', () => {
     cy.visit(`https://rom.my.universe.cdp.gigya.com`);
     cy.wait(5000); // Waiting here so the test won't finish immediately and wait for some requests to be fetched.
});

Cypress Version

10.9.0

Node version

v14.18.0

Operating System

Windows

Debug Logs

mjhenkes commented 2 years ago

Try enabling "experimentalModifyObstructiveThirdPartyCode", I'm not sure the page finishes loading correctly but the experimental flag removes the 'navigate back' behaviour you are seeing.

TiManGames commented 2 years ago

Unfortunately, setting that flag to true will just leave me with an infinite loading screen, so the initial page doesn't finish loading and the redirect will not occur.

mjhenkes commented 2 years ago

@TiManGames, something in the site you're testing is reacting negatively to being iframed in the test runner. modifyObstructiveCode and experimentalModifyObstructiveThirdPartyCode both attempt to modify the page as it's loaded to prevent frame busting. I definitely think your suspicion is correct that the page is manipulating history. I don't see any errors on the page to indicate why it's not loading.

I'll route this to our e2e team, but given our current issue volume, i'm unsure when we'll be able to take a look at it.

TiManGames commented 2 years ago

@mjhenkes Thank you for moving this forward, I appreciate it, even if it will take some time. Until then, I will update you in case I find any breakthrough with this.

dstaeber commented 1 year ago

I have a very similar issue. In my case a third-party login form is presented in an iframe. As soon as the form is submitted the cli output stops without any errormessage.

sandeepkuri commented 1 year ago

Hello, I'm also having the same issue in Open mode, Cypress test is stopping itself and I'm directed to the Specs page. I'm trying to click on a few popup frames

BriceCastaing commented 1 year ago

Hello, I'm facing the same issue at the end of an Yousign process (iframe). In Open mode the test will close itself and Cypress will go back to the main specs screen, in run mode it runs indefinitely.

shreenath17 commented 11 months ago

Hello, I'm facing the same issue. In Open mode the test will close itself and Cypress will go back to the main specs screen, in run mode it runs indefinitely.

tgemski commented 10 months ago

Same problem here after auth0 login page redirects me back, the test window is closing itself

nelsonds7 commented 10 months ago

Currently dealing with a similar issue, when the test navigates to a new page Cypress shuts down and goes back to the main specs page

DobQA commented 9 months ago

Hi, we have same issue that been trying debug for some time and hoping Cypress help. Each time we run our scripts and their is a "iFrame" naviagting away from the iFrame to a normal page causes cypress white screen or cypress crash - this seems to be issue as above.

DobQA commented 9 months ago

@mjhenkes See above multiple people reporting similar, you still feel this is on site level?

rifrafruf commented 8 months ago

Hello, i'm currently facing the same issue. In my case is where my scripts interact with an iFramed payment form. It seems the payment validation process was smooth after clicking on submit payment button but it suddenly just go back to the main specs screen before it reaches the correct confirmation page every single time.

rifrafruf commented 8 months ago

UPDATE: I found the issue that seems causing cypress to just go back to the select specs screen from my end, it seems that cypress is trying to open a New Window whenever it reaches the confirmation page. I notice this when i run the test using Firefox, the test will continue working until it opens the confirmation screen in a New Window even though it results in failed test since cypress was unable to validate the page that showing up in different window. The issue seems only happens in Chrome and Electron.

Note: this opening confirmation page in a new window behaviour never happened during the manual test, so it only happens in cypress

Anw, is there a way to force cypress to keep opening url even when it is form different origin in the same window?

DobQA commented 6 months ago

Is there someone I can tag from Cypress team to look into this:

Each time we run our scripts and there is a "iFrame" naviagting away from the iFrame to a normal page causes cypress just to display a white screen, nothing then happens, no actual cypress crash. Its very hard to debug this.

jhaider2 commented 4 months ago

I am having the same issue. After interacting with the Stripe iFrame the test returns to the spec page, no errors are thrown. If running in run mode the tests just hang and dont ever pass or fail.