0

This is my scenario: User A logs in and performs some actions on the webpage. After completing the actions, User B logs in to check if the changes made by User A are reflected on the webpage.

I wanted to use the cy.sessions method, but it is creating only one session, and the second session I cannot create because it is displaying a blank page. In Cypress documents, it says I can switch sessions inside the tests.

Does anyone know how to implement the multiple sessions in the it block ?

it block () {

    user A login
    do action()

    user B login
    verify ()
})

Commands.js file:

Cypress.Commands.add('session_Login', function (email, password) {

    cy.session(["ses1",email,password],()=>{

      cy.visit('/');

      cy.get('[data-automation-id="login-username-email-input"]').should('be.visible');
      cy.get('[data-automation-id="login-password-input"]').should('be.visible');
      cy.get('[data-automation-id="login-username-email-input"]').type(email);
      cy.get('[data-automation-id="login-password-input"]').type(password);
      cy.get('[data-automation-id="login-submit-button"]').click();
      cy.get('button[class*="iconDropDown"]').should('be.visible');
    })
})
Krokomot
  • 3,208
  • 2
  • 4
  • 20

0 Answers0