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.url() is an empty string after a redirect #5958

Open
1 of 6 tasks
that-ambuj opened this issue Oct 22, 2024 · 0 comments
Open
1 of 6 tasks

cy.url() is an empty string after a redirect #5958

that-ambuj opened this issue Oct 22, 2024 · 0 comments

Comments

@that-ambuj
Copy link

that-ambuj commented Oct 22, 2024

Description

When I'm testing the login flow via keycloak, the webpage would redirect to a url on localhost and when I try to get the current url using cy.url(), I'm getting an empty string.

URL of Issue(s)

N/A

Steps to replicate

  1. Start an oauth login flow, specifically keycloak.
  2. Use the correct username and password.
  3. Expect to be redirected to a callback url on your local/test server.
  4. Get redirected to an actual page like /home. Or manually call cy.visit('/home').
  5. Test that the cy.url() contains /home.

Browser

Chromium 129

Device

  • PC
  • Mac
  • iPhone
  • iPad
  • Android Phone
  • Android Tablet

Additional Information

The test body:

    const email = Cypress.env("username"),
      password = Cypress.env("password");

    cy.visit("/login");

    cy.get("#username").type(email);
    cy.get("#password").type(password);

    cy.contains("Sign In").click();
    cy.visit("/console");

    cy.url().should("match", /.*(\/console|\/teamspace\/create).*/);

Here's the screenshot starting from last third line of the test.

image

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

No branches or pull requests

1 participant