jeudi 23 juillet 2020

How to check a checkbox element according to the value in cypress while the value does not exist

How do I check a checkbox element according to the value in cypress, while the value attribute does not exist. I want to check the checkbox according to the value, not the id, because the id is different for each page.

enter image description here

Because in some pages, the id starts with c1, and some page ids start with c2, and some start with c5. How would I check the element according to value? I got the selector for all 3 checkboxes, but it checked all the 3 elements. I want specific element according to value attribute, but there there is no value attribute. i tried this

             cy.get('.x-overlay__wrapper--right input[type="checkbox"]').check()

but it checked all the element and this checked the first element

             cy.get('.x-overlay__wrapper--right input[type="checkbox"]').first().check()

but I want the checked according to value, but here in attributes there is no value attribute.

the value that i want is just written next to checkbox

enter image description here

and here in html enter image description here




Aucun commentaire:

Enregistrer un commentaire