testingtabsautomated-testscypress

Testing Cypress in two tabs at the same time


Testing Cypress in two tabs at the same time. I have read that Cypress does not support multiple tabs. However, there are many examples of surpassing this limitation. From them I did not fully understand whether it is possible to perform the test I need.

Tab 1
1.Log in under login A.
2. Perform actions
3. Wait for actions from another account to change state. Not closing the tab.

Open Tab 2
4. Log in with login B in a new tab 
5. Perform actions
6. Switch to tab 1, Refresh page
7. Check the changed state
8. Switch to tab 2. Perform action.
9. Switch to tab 1, Perform action.

Haven't tried anything yet. All the suggested questions on stackoverflow are old. Maybe there is an update how to do that ?


Solution

  • I ended up using a scheme like this:

    1. Login user A
    2. Test
    3. Save state from local storage to a variable
    4. Clear cookies, local storage
    5. Login user B
    6. Test
    7. Clear cookies, local storage
    8. Login user A with saved state
    9. Test
    cy.clearCookies();
    cy.clearAllLocalStorage();
    
    cy.loginWithArgs(login, password, URL);
    cy.setAuthDataArgs(access_token, refresh_token, savedUserState);