Skip to content

Cypress getting lose the Local session values at run time. #8037

@igopisrinivasan

Description

@igopisrinivasan

Cypress getting lose the Local session values at run time.

 

Current behavior:

 
Our Problem isthat, whenever we try to run a test UI request two XHR from a click in UI. One XHR keep on fail for Authorization.

In our Scenario, we try to access the token from authO and saved in the Session storage. So when we click a button in the UI. UI sending two XHR request and waiting for two response. Once first XHR response got, second XHR request getting failed in the Execution.
 
when we Run the same in Debugging mode, we observed Session Storage getting dropped.
 
When i retry the test a couple of times manually it works normal.
 
It seems to be an error connected to a Cypress browser. After it loads successfully, even opening new Mocha 'It' test and running tests in them.
 
Even worse is trying to test production web. It seems Cypress can not get authorized?

I constantly get 401 Unauthorized.
 
We're running under Single Sign On Bearer Token Authorization.
 

Desired behavior:

 
Session storage should not get drop at any number of request flow between client and server in any supporting browser
 

Test code to reproduce

 

describe('Sample Tests', () => {
  before(() => {
    cy.clearLocalStorageCache()
    cy.login()   // Via Single Sign On
  })
  beforeEach(() => {
    cy.restoreLocalStorageCache()
  })
  afterEach(() => {
    cy.saveLocalStorageCache()
  })
  after(() => {
    cy.clearLocalStorageCache()
  })

  after(function () {
    cy.logout()  // Custom Command Logout
  })

  it('Verify Adding value to the Home Page', () => {
    cy.visit('/home')
    cy.wait(3000)
    cy.get('#clientsDropdown > div').click()
    cy.wait(3000)
    cy.get(' div.ui-dropdown-items-wrapper > ul > p-dropdownitem:nth-child(4) > li').click()
    for (let i = 0; i < temp.length; i++) {
      let { XX, XXX } = temp[i]
      cy.get('table > tbody.ui-table-tbody>tr:nth-child(' + i + ')>td:nth-child(2)').contains('td', XXX).should('be.visible')
      cy.get('table > tbody.ui-table-tbody>tr:nth-child(' + i + ')>td:nth-child(3)').contains('td', XXX).should('be.visible')
    }
  })
})

image
 
Cypress.JSON

failOnStatusCode: false,
chromeWebSecurity: false,

 

Versions

 
Cypress: 4.10.0
Windows 10 (Version 2004)
Chrome 83

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions