I´m writing a Cypress test in which I want to confirm that a certain value is not shown. I want to check that my select element does not have an option with a certain value.
An example:
<select>
<option>A</option>
<option>B</option>
</select>
So now I want to check that there isn´t an option with value "C"
cy.get('select') // <-- here I want to verify that option "C" doesn´t exist
Can someone help me evaluate this?
Thanks.
Try this:
cy.get('select option:contains(C)').should('not.exist')
You can do like this:
cy.get('select option').eq(0).should('not.have.text', 'C')
Options and check that 'C' is not present:cy.get('select option').each(($ele) => {
expect($ele).to.not.have.text('C')
})