How to get div 'text' value in Cypress test using jquery
cy.get("WildnessText-kRKTej").then(function($elem) {
cy.log($elem.text())
})
One line validation:
Syntax:
cy.get(<selector>).invoke("text").should("eq", <your string>);
Example:
cy.get("div.myclass").invoke("text").should("eq", "My Text");
Here, following method is used for retrieving text. should()
is used for validation.
cy.get('element').invoke('text')
I might try this:
cy.get(".ibxudA").find('.WildnessText-kRKTej').should('have.text',"Wildness")
or
cy.get(".ibxudA").find('.WildnessText-kRKTej').invoke('text').then((text) => {
expect(text.trim()).equal('Wildness')
});
This might be a similar question: How do you check the equality of the inner text of a element using cypress?