Andy Harmuth
Andy Harmuth

Reputation: 11

cy.visit() generates GET request to different page than requested in run mode

I have a very basic Cypress test, per below

describe("Tests for Site users Page", () => {
  beforeEach(() => {
    cy.login();
  });

  it("visits the manage users page", () => {
    cy.visit("/sites/2/users");
    cy.contains("Contact Name").should("exist");
});

For some reason, Cypress does not visit /sites/2/users and instead goes to /sites/2/global (even though I did not request that). Can someone please tell me what is going on and how this issue can be resolved? In my cypress.json i have the baseUrl set to http://localhost:3002. Note, in the screenshot I have seen it says (new url) http://localhost:3002/sites/2/global directly after attempting to visit /sites/2/users

Upvotes: 0

Views: 329

Answers (1)

Fody
Fody

Reputation: 31862

This is a bit of wild-guess territory, but maybe the login is not successful, and /sites/2/global is the default page for not-logged-in.

To test it, check where do you go with cy.visit('/') and with cy.login() commented out for the moment.

If it's /sites/2/global, then cy.login() is the problem.

Upvotes: 1

Related Questions