Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Verify the checkbox is checked in Cypress

I want to verify the checkbox is checked. This is the HTML for the checkbox

enter image description here

the js for it:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    localShopClerkcheckbox(){
        return cy.get("[name='isLocalClerk']")
        //return cy.get(':nth-child(4) > .dx-box-flex > :nth-child(2) > .dx-item-content > .dx-last-col > .dx-field-item-content > .dx-show-invalid-badge > .dx-checkbox-container > .dx-checkbox-icon')
    }

Then on step definition:

Then("I see the Local Shop clerk is selected",() =>{
    backofficeCreateDeleteClerkPage.localShopClerkcheckbox().should('have.attr','aria-checked',true)

})

strangely Cypress shows that the expected value was true but the value was true

enter image description here

>Solution :

You have to change true to 'true'. The true is a string.

backofficeCreateDeleteClerkPage
  .localShopClerkcheckbox()
  .should('have.attr', 'aria-checked', 'true')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading