I am logging into application by using Cy.session() . it stores the session and restore the session for Next tests But some times when Cypress test runner automatically reloads on code update then it does not login and gives Error. May be the possible reason is cookie expire or something else . My code is :
login(username,password){
cy.session('sessionId', () => {
cy.visit('/');
this.getUsername().type(username);
this.getPassword().type(password);
this.getLoginButton().click();
cy.url().should('contain', '/inventory.html');
})
cy.visit('/inventory.html');
cy.url().should('contain', '/inventory.html');
}
Screenshot Attached :
I tried by adding the option cacheAcrossSpecs: true but it does not work