jeudi 5 janvier 2023

How to validate a checkbox is checked or not and then performing some action in Cypress?

<div class="ag-react-container"><div class="text-center"><input type="checkbox" class="" checked=""></div></div>
cy.("#checkbox").then(($ele) => {
   if($ele.next().is(':checked')){
      cy.("#checkbox").next().should("be.checked");
     }
   else {
     cy.("#checkbox").next().find("input").check();
     cy.("#checkbox").next().find("input").should("be.checked");
     }
  });

My problem is the code above is not going into if condition and keeps on executing else condition.

Learning cypress so code can be wrong and would expect correct full code along with some more examples of same if else condition check for buttons, checkboxes or elements.




Aucun commentaire:

Enregistrer un commentaire