Find row by the exact table cell text

Описание к видео Find row by the exact table cell text

Imagine that in this table we want to find the row with the second cell having the exact text "b". This video shows how to do this in two different ways:
cy.contains + cy.parent
cy.get + cy.filter

// select that cell in the second column with the exact test "b"
// using the cy.contains command
cy.contains('table tbody td:nth-child(2)', /^b$/)
.parent('tr')
.should('have.attr', 'data-k', '2')
// Alternative: use a custom cy.filter callback
cy.get('table tbody tr')
.filter(function (k, tr) {
return tr.children[1].innerText === 'b'
})
.should('have.attr', 'data-k', '2')

Find this and more recipes at https://glebbahmutov.com/cypress-exam...

Комментарии

Информация по комментариям в разработке