Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda