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

cy.origin redirects inside embedded browser window but url of embedded browser does not change (Chrome and Electron) #21988

Closed
sebamomann opened this issue May 31, 2022 · 5 comments
Assignees

Comments

@sebamomann
Copy link

sebamomann commented May 31, 2022

Current behavior

Upon clicking a "Login" button, the user gets redirected to the /account/login page (still localhost) and is then redirected to the (Keycloak) IDP where the user should log in.

After the successful login, the content of the embedded browser changes, since after a successful login my IDP (Keycloak) redirects back to the AUT. But in some cases (more often than not) the URL does not change appropriately. The URL still shows the IDP URL (https://account.sebamomann.de/auth) . The runner also shows an error message saying it is still waiting for the page to load.

image
Image shows faulty URL (still IDP URL) but correct content (localhost) while "waiting for new page to load"

Screenshot 2022-05-31 220552

After timeout the following error gets shown.

Screenshot 2022-05-31 220639

Behaviour is observable in Chrome 101 and Electron 100.
Working fine in Firefox 100.

Desired behavior

After a successful login on the IDP website the user shold be redirected back to the AUT (http://localhost:4200). The URL of the embedded Browser should also change, so further actions and URL comparisons can be made.

Test code to reproduce

beforeEach(() => {
  cy.login_button().click();
  cy.fixture('user/user-1.json').then(function (user) {
      cy.keycloack_login_via_ui_isolated(user);
    });
});

Custom command looks as follows

Cypress.Commands.add('keycloack_login_via_ui_isolated', (user) => {
  cy.origin(Cypress.env('KEYCLOAK_URL'), { args: { user } }, function ({ user }) {
    cy.get("#username")
      .type(user.username);
    cy.get("#password")
      .type(user.password);
    cy.get("[type=submit]")
      .click();
  });

  cy.origin("localhost:4200", () => {  
  });
});

Cypress Version

9.6.0, 9.6.1, 9.7.0

Other

behaviour is identical when not having

cy.origin("localhost:4200", () => {

});

after the testcase. This was just for debug purposes but has no effect.
Error is now just shown at the first cy.origin instead of the second cy.origin

image

Possibly related to #21363

@sebamomann sebamomann changed the title cy.origin redirects inside embedded browser window but url of embedded browser does not change (Chrome only) cy.origin redirects inside embedded browser window but url of embedded browser does not change (Chrome and Electron) May 31, 2022
@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Jun 2, 2022
@mschile
Copy link
Contributor

mschile commented Jun 2, 2022

@sebamomann, thanks for reporting this issue. Based on the login working correctly in Firefox I am inclined to believe that you are being impacted by our cookie handling. We are currently working on #20685 to improve our cookie handling.

I am going to close this issue as a duplicate of #20685. If you are still experiencing this issue after #20685 is resolved, please comment on this issue and we can reopen.

@mschile mschile closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2022
@mschile mschile removed the stage: investigating Someone from Cypress is looking into this label Jun 2, 2022
@idanElitzur
Copy link

Still happens to me on cypress 10.7.0.
can you please post a reference how to handle this use case?
thanks

@sebamomann
Copy link
Author

I just revalidated it with 10.3.0, 10.7.0 and 10.8.0. All versions work fine in my case.
Could not reproduce the error.

@idanElitzur
Copy link

Actually this happens to me only when I'm using Chrome browser v105x
when using electron the load errors are not returning and the origin it works but the cookies of the session are not passing inside and the flow can't be done :/

@sebamomann
Copy link
Author

Said runs were on Chrome 104.
Tested Cypress 10.7.0 and 10.8.0 on Chrome 105. Works fine on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants