cypress-io / cypress

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

Page goes into infinite refresh loop(Phoenix Liveview websites) #29690

Open bynasrivastav99 opened 4 months ago

bynasrivastav99 commented 4 months ago

Current behavior

When navigating from any page to another page which uses Phoenix Liveview, the page goes into infinite refresh loop. In the below code I first visit a website(could be any website) and from that website I try redirecting to another webpage(website made using Phoenix Liveview) and try and click on 'Get-Started' button. But as soon as cypress redirects to the concerned page it starts to refresh and keeps on refreshing and the execution of test lines does not move forward. Note: If we navigate directly to page using Phoenix Liveview, the refresh issue does not seem to happen.

https://github.com/cypress-io/cypress/assets/153902001/ca051175-9364-4892-8d0d-c339d4775ed9

Desired behavior

The test should first visit the given webpage, then navigate to another given webpage and click on 'Get-Started' button thus opening sign-in pop-up.

Test code to reproduce

/// <reference types="Cypress" />

describe("Visit", () => {
  it("visit testcase", () => {
    cy.visit("https://elixirstream.dev/regex");//Can visit any webpage
    cy.visit('https://rocketvalidator.com/');//Website made by elixir+Phoenix LV
    cy.contains('Get Started').click();
    //Below are a list of few website which produce same behaviour.
     //cy.visit('https://www.intelidoc.io/');
    // cy.visit('https://2024.elixirconf.com/');
    //cy.visit("https://websocketstest.com/ ");
  });
});

Cypress Version

13.11.0

Node version

v21.4.0

Operating System

Windows 11 Pro

Debug Logs

No response

Other

No response

srivastav99 commented 2 months ago

Hi @jennifer-shehane , any update on this.

jennifer-shehane commented 2 months ago

I'm no seeing this exact issue with the information provided. I get this error:

Screenshot 2024-08-05 at 11 22 56 AM

srivastav99 commented 2 months ago

Hi @jennifer-shehane , for that particular code, i too am getting the same issue. Please try with following below code:

describe("Visit", () => {
  it("visit testcase", () => {

    cy.visit("https://elixirstream.dev/regex");//Can visit any webpage
    cy.visit('https://2024.elixirconf.com/');

    //Below are a list of few website which produce same behaviour.
    //cy.visit('https://www.arta.io/contact-us');
    //cy.visit('https://arta-us.sothebys.com/');
    //cy.visit('https://www.intelidoc.io/');
    //cy.visit('https://rocketvalidator.com/');//Website made by elixir+Phoenix LV
    //cy.contains('Get Started').click();
  });
});
srivastav99 commented 2 months ago

This is the screencast of results for the above code:

https://github.com/user-attachments/assets/c112b425-1276-458e-99e5-3bd27f00c396

srivastav99 commented 2 months ago

Hi @jennifer-shehane , any further update on this.

jennifer-shehane commented 1 month ago

I am able to see this behavior of infinite reloading of the AUT website with no resolution in the tests while running the below code in 13.13.3.

  it("visit testcase", () => {
    cy.visit("https://elixirstream.dev/regex");//Can visit any webpage
    cy.visit('https://2024.elixirconf.com/');
})

This used to accurately show an error about how you should use cy.origin in this case of visiting two different superdomains. But in 12.0.0 this just started looping through trying to resolve the new visit.

@srivastav99 Call cy.origin for this second visit instead of cy.visit to get around this.

Screenshot 2024-08-26 at 2 52 14 PM

jennifer-shehane commented 1 month ago

Ok, actually this shouldn't error - the origin error will actually only display if you run commands against the new origin in v12. I'm not sure why this is infinitely reloading, it certainly shouldn't