Cypress page not found meanwhile it works when I load it manually

  automated-tests, cypress, javascript

I’m using cypress-cucumber-preprocessor

I’m using Sauce Labs demo app for automation testing, https://www.saucedemo.com/

I have a step that is supposed to visit the homepage that has the following url:
https://www.saucedemo.com/inventory.html

I have the baseUrl defined in my cypress.json as shown below:

cypress.json

{
    "baseUrl": "https://www.saucedemo.com/",
    "testFiles": ["**/*.{feature,features}"],
    "chromeWebSecurity": false,
    "env": {
        "fixturesBaseDir": "test_data_files/"
    }
}

And my step definition as shown below:

When("go back to home page", () => {
  cy.visit("/inventory.html");
});

When I go to the home page manually: https://www.saucedemo.com/inventory.html
But when I execute my step I get the following error:

cy.visit() failed trying to load:

https://www.saucedemo.com/inventory.html/

The response we received from your web server was:

  > 404: Not Found

This was considered a failure because the status code was not 2xx.

If you do not want status codes to cause failures pass the option: failOnStatusCode: false

Screenshots

Cypress Error

Screen

Source: Ask Javascript Questions

LEAVE A COMMENT