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

214
Visualizações
How to exclude certain element from checks

Hey guys i have a table that consist of some rows and columns where one of the columns can be empty so i want to exclude it somehow.

Currently i am checking like this which looks like there is to much not needed writings

  cy.get('tr td.cdk-cell.amount.cdk-column-Amount').each(($column) => {
    expect($column).to.not.be.empty
 })

 cy.get('tr td.cdk-cell.cryptocurrency.cdk-column-BTC').each(($column) => {
  expect($column).to.not.be.empty
})
cy.get('tr td.cdk-cell.status.cdk-column-Status').each(($column) => {
  expect($column).to.not.be.empty
})

I cannot do the following since one of the columns always empty

cy.get('tbody[role="rowgroup"] tr td').each(($ele) => {
  expect($ele.text().trim().length).to.be.at.least(1)
})

So my question is how to ignore 1 column and check if all others have value present

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

0

Break down the selectors a bit, use .each() over the rows because it's per-row test (I presume that is correct?).

Inside the row, get the isEmpty result of all the columns you are interested in.

Them combine the isEmpty variables into one result you can test.

cy.get('tbody[role="rowgroup"] tr').each(($tr, rowIndex) => {

  const amountCol = $tr.find('td.cdk-cell.amount.cdk-column-Amount');
  const cryptoCol = $tr.find('td.cdk-cell.cryptocurrency.cdk-column-BTC');
  const statusCol = $tr.find('td.cdk-cell.status.cdk-column-Status');

  const amountIsEmpty = amountCol.is(':empty')   // result is true/false
  const cryptoIsEmpty = cryptoCol.is(':empty')
  const statusIsEmpty = statusCol.is(':empty')

  const allAreEmpty = amountIsEmpty && cryptoIsEmpty && statusIsEmpty;
  if (allAreEmpty) {
    throw new Error(`Row ${rowIndex} has all three columns empty`)
  }
  // or
  expect(allAreEmpty).to.eq(false);
})
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