Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Cypress - Automatic logout after 5 running functions

I found this code for cypress which is ideal for storing cookies and not delegating the test after the first function.

Link from article: https://dzone.com/articles/cypress-preserve-cookies-and-keep-login-session-active-in-tests

Unfortunately, during the execution of the fifth function in my code, the application is logged out.

afterEach(() => {
                //Code to Handle the Sesssions in cypress.
                //Keep the Session alive when you jump to another test
                let str = [];
                cy.getCookies().then((cook) => {
                    cy.log(cook);
                    for (let l = 0; l < cook.length; l++) {
                        if (cook.length > 0 && l == 0) {
                            str[l] = cook[l].name;
                            Cypress.Cookies.preserveOnce(str[l]);
                        } else if (cook.length > 1 && l > 1) {
                            str[l] = cook[l].name;
                            Cypress.Cookies.preserveOnce(str[l]);
                        }
                    }
                })

The last function looks like this:

it('Start Creating New Appointment ',function () { 
    cy.get('.user-box__input .dx-dropdowneditor-icon').first().click()
    cy.get('.dx-calendar-contoured-date').click()

    cy.get('.user-box__input .dx-dropdowneditor-icon').eq(1).click()
    cy.contains('01:30 AM').click() 

    cy.get('.dx-dropdowneditor-button .dx-button-content').eq(2).click()
    cy.wait(1000)
    cy.get('.dx-item-content dx-list-item-content').eq(2).click()


    cy.get('.dx-dropdowneditor-button .dx-button-content').eq(3).click()
    cy.wait(1000)
    cy.get('.dx-list-item-content').eq(2).click()

    cy.contains('Save').click()
    cy.wait(2000)

})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!