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

213
Views
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 answers
Answer question

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 Report
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!