cypress icon indicating copy to clipboard operation
cypress copied to clipboard

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

Open TiManGames opened this issue 3 years ago • 17 comments

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

TiManGames avatar Oct 02 '22 14:10 TiManGames

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

mjhenkes avatar Oct 03 '22 19:10 mjhenkes

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.

TiManGames avatar Oct 03 '22 21:10 TiManGames

@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.

mjhenkes avatar Oct 05 '22 16:10 mjhenkes

@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.

TiManGames avatar Oct 05 '22 17:10 TiManGames

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.

dstaeber avatar Feb 16 '23 12:02 dstaeber

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

sandeepkuri avatar Jul 18 '23 16:07 sandeepkuri

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.

BriceCastaing avatar Aug 18 '23 12:08 BriceCastaing

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.

shreenath17 avatar Nov 10 '23 09:11 shreenath17

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

tgemski avatar Dec 21 '23 16:12 tgemski

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

nelsonds7 avatar Jan 03 '24 15:01 nelsonds7

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 avatar Jan 22 '24 10:01 DobQA

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

DobQA avatar Jan 22 '24 10:01 DobQA

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 avatar Feb 15 '24 09:02 rifrafruf

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?

rifrafruf avatar Feb 26 '24 04:02 rifrafruf

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.

DobQA avatar Apr 18 '24 10:04 DobQA

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.

jhaider2 avatar Jun 10 '24 21:06 jhaider2