Skip to content

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

Open
@that-ambuj

Description

@that-ambuj

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions