I want to verify the checkbox is checked. This is the HTML for the checkbox
the js for it:
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
Advertisement
Answer
You have to change true
to 'true'
. The true is a string.
backofficeCreateDeleteClerkPage .localShopClerkcheckbox() .should('have.attr', 'aria-checked', 'true')