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

245
Visualizações
Cypress: check the value of a cell in a table using polling

I have a table that has a status column, I want to check the status of the fist row (which is at last column) . the status goes from "in progress" to completed after some amount of time (max 5 min);

here is the DOM:

<tbody>
   <tr>
      <td>...</td>
      <td> ... </td>
      <td> in progress / complete </td> //status => want to check this cell.
  </tr>
   <tr>
      <td>...</td>
      <td> ... </td>
      <td> ... </td> //status
  </tr>
   <tr>
      <td>...</td>
      <td> ... </td>
      <td> ... </td> //status
  </tr>
</tbody>

how to reach to the cell I want and use polling mechanism to see if the status completed?

thank you for your help

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

I would first check the "in progress" status to ensure the sequence is correct.

cy.contains('tbody tr:eq(0)', 'in progress')
cy.contains('tbody tr:eq(0)', 'complete', {timeout:300000})
about 4 years ago · Juan Pablo Isaza Relatório

0

The pattern for selecting row and column in Cypress would be

cy.get('tbody tr').eq(0)          // first row
  .find('td').eq(2)               // third col
  .should('contain', 'complete')  // criteria to check 

This waits for the defaultCommandTimeout setting which is 4000 ms. To extend to 5 minutes add a 300000 timeout.

cy.get('tbody tr').eq(0)              
  .find('td').eq(2, {timeout:300000})  
  .should('contain', 'complete')      // on fail retry above up to 5 minutes

But you might get errors with this depending on what changes in the DOM after status is updated. If the row or the table are refreshed with a new copy, you might need to combine the steps into one selector.

cy.get('tbody tr:nth-child(1) td:nth-child(3)', {timeout:300000})           
  .should('contain', 'complete') 

It's not always clear which steps in a command chain will be repeated when .should() fails.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can also use within to go inside the first tr and wait for the desired amount of time for the text complete to appear. Something like this:

For exact text match:

cy.get('tbody')
  .find('tr')
  .eq(0)
  .within(() => {
    //eq(0) gets the first tr
    cy.get('td', {timeout: 300000}).eq(2).should('have.text', 'complete') //Exact text match
  })

For Partial text match:

cy.get('tbody')
  .find('tr')
  .eq(0)
  .within(() => {
    //eq(0) gets the first tr
    cy.get('td', {timeout: 300000}).eq(2).should('contain.text', 'complete') //partial text match
  })
about 4 years ago · Juan Pablo Isaza Relatório
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