1

I am trying to Click on a Button that submits the inputs during the automation in Cypress. While performing manual entry the data is submitted but while submitting through Cypress the input doesn't submit and leads to Status Code: 401 Unauthorized. Cypress Test Runner

  context("Checking Add Importer Functionality", () => {
  it("submits the form accepting only the mandatory field", () => {
 
  cy.login(data.username, data.password);
  cy.get("[title=Static]").click().url().should("include", "/importer");
  cy.get(".css-1uccc91-singleValue")
    .contains("Importer")
    .type("importer {enter}");
  cy.get(".buttontext").contains("Add Importer").click();
  cy.get("[placeholder=Name]").should("be.visible").type("Ironman");
  cy.get("[name=nameNp]").should("be.visible").type("Ironman");
  cy.get("[name=eximCode]").clear().type("1234567891234");

  cy.get("[type=submit]").click();

Used Preserve Once

1 Answers1

0

You can try & check by preserving your browser cookies Ex:

beforeEach(() => {

        Cypress.Cookies.preserveOnce('<id>')
})

https://docs.cypress.io/api/cypress-api/cookies#Preserve-Once

Pali
  • 126
  • 3