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

251
Views
How to target a checkbox that has no id, name and class attribute?

I am trying to target a checkbox using cypress that has no id and classname and assert it is checked on click. I have tried a couple of ways including this and it does not work.

cy.get('[type=checkbox]').select('Store')

The code looks like this

<h2>
  <input type="checkbox" 
         tri-state="" 
         ng-model="data.root" 
         class="ng-valid ng-touched ng-dirty ng-valid-parse">Store 
</h2>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

.select() is for dropdowns (well some of them), but .check() is for checkboxes docs

cy.contains('h2', 'Store')
  .find('[type=checkbox]')
  .check()

There's something a little bit off with the html, the <input> isn't closed. Probably does not matter, but to be safe id the <h2> with the "Store" text, then .find() takes you inside the <h2>.

over 4 years ago · Santiago Trujillo 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!