Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

74
Views
Cypress select does not have value

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.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try this:

cy.get('select option:contains(C)').should('not.exist')
about 4 years ago · Juan Pablo Isaza Report

0

You can do like this:

  1. For a specific position, you can check like this:
cy.get('select option').eq(0).should('not.have.text', 'C')
  1. You can also loop over all the Options and check that 'C' is not present:
cy.get('select option').each(($ele) => {
  expect($ele).to.not.have.text('C')
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!