Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda