Getting 404 error | Server Error | cy.visit() failed trying to load

3.5k Views Asked by At

URL: https://portal-sms-staging.eggdigital.com/signin

Cypress.Json

"chromeWebSecurity": false,
"testFiles": "**/*.{feature,features}",
"ignoreTestFiles": ["**/stepDefinitions/*","*.js", "*.md"],
"reporter": "mochawesome",
"reporterOptions": {
    "reportDir": "cypress/report/mochawesome-report",
    "overwrite": true,
    "charts": true,
    "html": true,
    "json": false,
    "timestamp": "mmddyyyy_HHMMss"
    
 }

}

static loadHomePage(){

    //cy.on('uncaught:exception', (err, runnable) => { return false; })
    cy.visit('/signin', { timeout: 80000 })
    
    cy.url().should('include', 'eggdigital')
}

Error getting: cy.visit() failed trying to load:

https://portal-sms-staging.eggdigital.com/signin

The response we received from your web server was:

404: Not Found

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

This http request was redirected '1' time to:

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

enter image description here

3

There are 3 best solutions below

0
On

I've searching for solution many times, and found:

when browser: send request header and response status code OK when using cy.visit(): response status code Not Found

So the problem is request header, you better check it, and set Headers when you visit look like browser Headers to recived status code OK.

0
On

Try to set failOnStatusCode: false inside visit parameters

0
On

You can just pass 'failOnStatusCode': false in visit action:

cy.visit('your URl', {'failOnStatusCode': false})