jeudi 25 février 2021

cypress redirects to the new url automatically on it("",()=>{}) function

/// <reference types="cypress"/>

cy.get("#email").type("cypress@cypress.com");
cy.get("#password").type("khuljasimsim");

const productName = 123;
let discount = 200;
let price = 0;

describe("add product", () => {
  it("login", () => {
    cy.visit("https://web-panels.herokuapp.com/store-login");
    cy.get("#email").type(userName);
    cy.get("#password").type(password);
    cy.get(".form-check-input").click();
    cy.get(".btn").click();
  });

  it("should route to add poduct", () => {
    cy.get(":nth-child(2) > .nav-link").click();
    cy.get(".leftBorder").click();
  });

  it("should not allow if price is 0(zero)", () => {
    // Error: Automatically redirecting to the new url https://web-panels.herokuapp.com/store-login
    price = 0;
    cy.get(":nth-child(2) > .form-group > .form-control").type(price);
    cy.get(":nth-child(2) > .form-group > .form-control").should(
      "have.text",
      ""
    );
  });

As I execute the cypress test, as it reaches to the third it. Test automatically calls cy.visit("https://ift.tt/3krsHor); which I even did write in the the third it. What is the solution to prevent it redirecting to the unexpected new URL(https://web-panels.herokuapp.com/store-login) and why it is being happened.

Following snippet is cypress test execution, you would find the new URL in the snippet. Cypress test execution logs

Aucun commentaire:

Enregistrer un commentaire