I'm trying to find in a table my row that cy.contains() a specific text.
I cannot do:
cy.get("tr").contains("specific text")
That will return my span element containing the text
I cannot do
cy.get("tr").contains("specific text").parent()
beacause the parent of the span my not be my
I cannot do
cy.get("tr").contains("specific text").parentUnitl("tr")
That will not return the element
I probably could do
cy.get("tr").contains("specific text").parentUnitl("tr").parent()
But I think that's becoming really complex for such a simple thing.
Am I missing something?
Thanks
You can do
cy.contains("tr", "specific text")
which will return the <tr>
even though the text is in a descendent <span>
.
It will also have better retry ability than cy.get().contains()
if the row loads asynchronously.