Cypress testing pseudo CSS class :before

后端 未结 4 1420
囚心锁ツ
囚心锁ツ 2021-02-15 09:55

Is there a way in which I can test the content of the pseudo CSS class for :before on my element with Cypress?

I have seen links documenting:

4条回答
  •  独厮守ぢ
    2021-02-15 10:02

    Try asserting on the text of the parent:

    cy.get('.myClass').parent().should('have.text', 'foo-bar')
    

    If that doesn't work, you may have to use the textContent property:

    cy.get('.myClass').parent(). should($el => expect ($el).to.contain('foo-bar')
    )
    

提交回复
热议问题