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

Cypress Test runner getting exit while redirect #23751

Open
nitish-Datman opened this issue Sep 9, 2022 · 29 comments
Open

Cypress Test runner getting exit while redirect #23751

nitish-Datman opened this issue Sep 9, 2022 · 29 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@nitish-Datman
Copy link

nitish-Datman commented Sep 9, 2022

Current behavior

while running the test , cypress runner getting disappeared on redirect,

Desired behavior

cypress runner should still be visible on redirect

Test code to reproduce

describe("test", function () {
  it("create payment", function () {

cy.visit(*********) //provide any url that redirect to another url 
})
})
cypress_redirect_error.mov

Cypress Version

10.6.0

Node version

v16.16.0

Operating System

macOS 11.2.3

Debug Logs

No response

Other

No response

@nitish-Datman
Copy link
Author

@emilyrohrbough let me know if this can be resolved

@emilyrohrbough
Copy link
Member

@nitish-Datman It appears the redirect is busting out of the AUT (application under test) iframe. Have you tried/considered enabling modifyObstructiveCode to see if this prevent this behavior?

@nitish-Datman
Copy link
Author

@emilyrohrbough i have tried , did not help

@Yonhoo
Copy link

Yonhoo commented Sep 13, 2022

i meet the same issue, when request my domain , the response submit redirect html ,then cypress runner getting exit, jump to redirect domain , can i know cy.origin can cover it?

@nitish-Datman
Copy link
Author

@jennifer-shehane can this be resolved please

@chrisbreiding
Copy link
Contributor

Right now there doesn't seem to be enough information to reproduce the problem on our end. Unless we receive a reliable reproduction, we'll eventually have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please provide a reproducible example of the issue you're encountering. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.

@nitish-Datman
Copy link
Author

nitish-Datman commented Sep 16, 2022

describe("Test", function () {
  it("Test flow", function () {

    cy.visit('http://shorturl.at/IMNQV')
    cy.get(nameOnCard_input, { timeout: 25000 }).type("nitish");

    cy.get("#cardNumber")
      .iframeLoaded()
      .its("document")
      .getInDocument('input[name="cardnumber"]')
      .type('4929421234600821');

    cy.get("#expiryDate")
      .iframeLoaded()
      .its("document")
      .getInDocument('input[name="exp-date"]')
      .type('1123');

      cy.get("#cvv")
      .iframeLoaded()
      .its("document")
      .getInDocument('input[name="cvc"]')
      .type('356');

      cy.xpath("//body/div[@id='__next']/div[1]/section[2]/div[2]/div[1]/form[1]/div[1]/button[1]")
      .click()


   });
});`

add this in command.js

Cypress.Commands.add(
  'iframeLoaded',
  { prevSubject: 'element' },
  ($iframe) => {
    const contentWindow = $iframe.prop('contentWindow')
    return new Promise(resolve => {
      if (
        contentWindow &&
        contentWindow.document.readyState === 'complete'
      ) {
        resolve(contentWindow)
      } else {
        $iframe.on('load', () => {
          resolve(contentWindow)
        })
      }
    })
  })
Cypress.Commands.add(
  'getInDocument',
  { prevSubject: 'document' },
  (document, selector) => Cypress.$(selector, document)
)

@chrisbreiding i have added the code snippet to replicate the issue , hope this helps

@chrisbreiding
Copy link
Contributor

I'm unable to reproduce the issue with the code provided. The variable nameOnCard_input is undefined. If I substitute it with a selector for the only input on the page visited, the next command (cy.get("#cardNumber")) fails because there's no element with an id of cardNumber on the page.

@nitish-Datman
Copy link
Author

@chrisbreiding apologises as i missed to add the locator for nameOnCard_input here is the locator for the same #nameOnCard and for (cy.get("#cardNumber")) its an iframe , you need to add the iframe support command line in the command.js page as mentioned above.

proving you few urls as it gets expired after visiting once,
- https://shorturl.at/eimqZ
- https://shorturl.at/EKX45
- https://shorturl.at/cirS1
- https://shorturl.at/hpruw

@chrisbreiding
Copy link
Contributor

Unfortunately none of those urls worked. It's possible, since they're links, a web crawler is picking them up and invalidating them by visiting the url. Could you post a few more, but just the IDs (so they don't turn into links)?

@nitish-Datman
Copy link
Author

here are the url id's below,

@nitish-Datman
Copy link
Author

seems like all the urls are expiring , i'm adding in the sheet https://docs.google.com/spreadsheets/d/1z08dCTFnGuqmPWmHmaWFY9kGxFwPxgjqZ03NaovQ644/edit?usp=sharing

once you request for access will provide the same

@nitish-Datman
Copy link
Author

@chrisbreiding shared

@chrisbreiding
Copy link
Contributor

I was able to get the example code running by visiting one of the urls in the sheet, but the test passes and I don't see any failures or a redirect happening. Although the click command succeeds at the end, it doesn't seem to have any effect, so it doesn't go as far as the test in your video.

I know you tried using modifyObstructiveCode and it didn't work, but this might require using experimentalModifyObstructiveThirdPartyCode. Can you trying setting that to true in your cypress.config.js and see if it helps?

@nitish-Datman
Copy link
Author

it didn’t help, now the wired part is while experimentalModifyObstructiveThirdPartyCode: true, adding this to cypress.config.js iframe is not even loading ,
for iframe to load now i have to give now modifyObstructiveCode: false without experimentalModifyObstructiveThirdPartyCode , no idea what has changed

@chrisbreiding
Copy link
Contributor

chrisbreiding commented Sep 23, 2022

Interesting, I was able to reproduce the issue after setting modifyObstructiveCode: false. Now that I've reproduced it, I'm going to route this to a team to look into.

Here are debug logs I captured when reproducing the issue:
debug.log

@vivekbaskaran24021
Copy link

@chrisbreiding When is the issue is planned to fix

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. and removed routed-to-e2e labels Apr 19, 2023
@snehithapothina
Copy link

I am facing the same issue, Can any one share the solution if possible?
while running the test , cypress runner getting disappeared on redirect,

@requireSol
Copy link

Same here but my dashboard just get restarted.

@kamilf92
Copy link

kamilf92 commented Jun 7, 2023

Same here my dashboard get restarted. I tried to use modifyObstructiveCode and experimentalModifyObstructiveThirdPartyCode but without success

@jan-trynda-crustlab
Copy link

jan-trynda-crustlab commented Sep 4, 2023

I noticed, that in my case that issue mostly exists while using Chrome - both Edge and Electron work fine most of the time (it still happens from time to time)
Looking forward for it to be fixed

@crismarycastellanos
Copy link

Hello, this is happening to me with the same payment platform! we are simulating a payment and once we confirm it redirects to a new page and the Cypress sidebar disappears! Just like in the video, what can we do ?? is there any workaround ??

@snehithapothina
Copy link

snehithapothina commented Dec 8, 2023 via email

@DobQA
Copy link

DobQA commented Jan 22, 2024

Any news on this issue, seems we facing something similar.

@gloAman
Copy link

gloAman commented Feb 15, 2024

Any update on the issue?

@Sarcolemna
Copy link

I am getting this issue as well. The behavioral difference being that when the redirect fires the Cypress controls disappear and the non AUT browser resolves to the redirected page. This makes the headed runner basically unrecoverable and require a restart.

@PK-Tests
Copy link

I have the same issue. Because of security reasons i cant provide any reproducible code, but the problem for me happens when a payment gate redirects to authentication page. For a second the GUI shows "Your tests are loading..." and then exits out of the current test to the Specs list.

I tried both modifyObstructiveCode and experimentalModifyObstructiveThirdPartyCode unfortunately with no luck.

@jennifer-shehane jennifer-shehane added stage: needs investigating Someone from Cypress needs to look at this type: bug and removed E2E Issue related to end-to-end testing labels May 21, 2024
@Marrkkov
Copy link

I have the same issue. Because of security reasons i cant provide any reproducible code, but the problem for me happens when a payment gate redirects to authentication page. For a second the GUI shows "Your tests are loading..." and then exits out of the current test to the Specs list.

I tried both modifyObstructiveCode and experimentalModifyObstructiveThirdPartyCode unfortunately with no luck.

I am experiencing exactly the same issue with a payment gateway for an e-commerce platform. Unfortunately, I cannot provide the code for security reasons. Is there any news on this issue? I have tried many workarounds, but nothing has worked for me so far.

@dil-aman2
Copy link

I am facing same issue. tried with all mentioned options but no luck. Any update by when we will get the solution in this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet
Development

No branches or pull requests