0

I have the following redirection scenario that I want my Cypress test to allow:

  1. My frontend code on domain A, redirects to server on domain B.
  2. Server B, redirects to domain C.
  3. Domain C, returns\redirects back to domain B.
  4. Domain B redirects back to domain A.

I tried using cg.origin(), but it support only one redirection.

In every way I tried, I eventually got: chrome-error://chromewebdata/

I tried mocking the first redirection (from client-side to the remote server), but again, I got chrome-error://chromewebdata/ for the B->A redirection.

How can I solve this problem?

1 Answers1

3

I would follow this similar question How to handle multiple redirects to different origins in Cypress

The solution is to apply cy.origin() for each redirect testing the page elements of the URL at each step.

cy.visit('http://127.0.0.1:3000')
cy.get('h1').contains('Base page')                       

cy.origin('http://127.0.0.1:5500/html/redirect1.html', () => {
  cy.get('h1').contains('Redirect 1')                        
  cy.get('button').contains('Redirect').click()
})  

cy.origin('https://example.com', () => {
  cy.get('h1').contains('Example Domain')              
})

The answer has a nice reproduction of the problem so you can try it independently of your own application, which is useful since you don't seem to have given concrete details.

Since you are "going back to A", you can leave A as the main domain.

Rubio
  • 31
  • 2
  • Thanks @Rubio, I tried your solution but I the problem remains. The problem is that the return/redirection to A is what making the problem, since it server B is handling it, and I can't control/monitor it from cypress. – Ofer Aharoni Jul 11 '23 at 05:04