Cypress testing pseudo CSS class :before

后端 未结 4 1270
我在风中等你
我在风中等你 2021-02-15 09:50

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:24

    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')
    )
    

提交回复
热议问题