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

183
Views
Cypress gets 401 error and logs out during the test

I'm facing an issue which I couldn't solve yet and wanted to get some opinions from you. I've a selector which has two options in total and I'm using select to switch between them. I wasn't sure about the code so I added url check as well, which works successfully.

However, the page loads with the first selection so the api call has already been made, but, in the second part (items section) when I select Items it throws 401 error and logs out which breaks all the following tests.

What can I do/improve here? This flow works perfectly on my local but Cypress fails.

Things I've tried:

  • selecting using 0 and 1 without value names.
  • tried with {failOnStatusCode: false}.
  • couldn't use Cypress.Cookies.preserveOnce (since it's deprecated).
  • I also tried this one as well here; https://www.youtube.com/watch?v=b8aoVh6IdCg

Thanks in advance!

Screenshot

Screenshot2

it('verifies there are only orders, drafts and/or return orders on all orders grid', () => {
  ordersPage.ordersSelector().trigger('click')
          cy.get('select').select('orders').should('have.value', 'orders');
          cy.url()
            .should('include', 'orders');
    const orderNumberPrefix = ['DRAFT-', 'SO0', 'S0-', 'R0']
    cy.get('.ag-center-cols-container div[row-index]')
      .each($row =>{
        const $col = $row.find('[col-id="orderNumber"]')
        const orderNumber = $col.text().trim()
        const correctOrderNumberPrefix = orderNumberPrefix.some(prefix => {
          return orderNumber.startsWith(prefix)
        })
        expect(correctOrderNumberPrefix).to.be.true;
      });
    })

it('verifies there are only orders on items grid', () => {
  ordersPage.ordersSelector()
          cy.get('select').select('items').should('have.value', 'items'); //fails here
          cy.url()
            .should('include', 'items');
    const orderNumberPrefix = ['SO0']
    cy.get('.ag-center-cols-container div[row-index]')
      .each($row =>{
        const $col = $row.find('[col-id="orderNumber"]')
        const orderNumber = $col.text().trim()
        const correctOrderNumberPrefix = orderNumberPrefix.some(prefix => {
          return orderNumber.startsWith(prefix)
        })
        expect(correctOrderNumberPrefix).to.be.true;
      });
    })
almost 4 years ago · Santiago Trujillo
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!