I try to read out a table and compare all textvalues. If there are two times the same value, the test should fail. I try this by using a counter. If counter == 2 then fail. But I cant enter the if-statement, cause cypress cant compare the textvalue..
let duplicateCounter = 0
cy.get('[data-cy="projectList"]')
.find('[data-cy="project.name"]') // I'm using my own marker for my table
.each((MyElement, MyIndex, MyContentOfArray) => {
cy.wrap(MyElement.text())
.then( (tmp) => {
cy.log('tmp = ' + tmp)
if(tmp == "001_AA_Testproject") // it never enters the if-Block, cause textcomparing isnt working
{
cy.log('============================================ if Block ' )
duplicateCounter += 1
}
cy.log('duplicateCounter = ' + duplicateCounter)
})
cy.get(duplicateCounter ).should('eq',1)
How can I use if-Statements in .each()-loops?
Aucun commentaire:
Enregistrer un commentaire