How to create sessions in Cypress?
Agenda of this Tutorial
1. How to create a session in the Cypress? importance of sessions in Cypress?
2. How can cache the cookies in Local torage?
3. How to set the Assertions for Cookies?
4. How to Validate the Cookies?
5. How to Apply cy.session() to the whole project?
beforeEach(()=>{ cy.session('login',()=>{ cy.visit('/') cy.get('#login2').click() cy.wait(3000) cy.get('#loginusername') .type('CypressAutomation',{setTimeout:4000}) cy.get('#loginpassword') .type('123456{enter}', { log: false }); cy.get('#logInModal > .modal-dialog > .modal-content > .modal-footer > .btn-primary').click() },{ validate(){ cy.document() .its('cookie') .should('contain','tokenp_') .then(token =>{ cy.request({ url:'/favicon.ico', headers:{ token } }) }) } } ) })
Video Tutorial available at :
[…] is available at : https://softans.com/cy-session-in-cypress/ Testing Website Link is : […]