jeudi 25 avril 2019

How to console text in an element using Cypress?

I am using Cypress for testing. I want to make sure that certain data is collected when on the page, but that does not show in the html. I have added hidden html elements for this purpose, which looks like this:

<div class="hidden">
    <p id="c.campaign">3005</p>
</div>

Now I want to use my Cypress test to make sure that there is a campaign saved to the page. This is what I have so far:

cy.get('#c.campaign').should('not.be.visible').invoke('text').then((text) => {
    cy.log(text)
})

The should not be visible is necessary as the element it hidden and does not find it otherwise. It should be logging 3005 but nothing is appearing. failed test

Aucun commentaire:

Enregistrer un commentaire