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:
JavaScript
x
5
1
<select>
2
<option>A</option>
3
<option>B</option>
4
</select>
5
So now I want to check that there isn´t an option with value “C”
JavaScript
1
2
1
cy.get('select') // <-- here I want to verify that option "C" doesn´t exist
2
Can someone help me evaluate this?
Thanks.
Advertisement
Answer
Try this:
JavaScript
1
2
1
cy.get('select option:contains(C)').should('not.exist')
2