I want to verify the checkbox is checked. This is the HTML for the checkbox
the js for it:
JavaScript
x
5
1
localShopClerkcheckbox(){
2
return cy.get("[name='isLocalClerk']")
3
//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')
4
}
5
Then on step definition:
JavaScript
1
5
1
Then("I see the Local Shop clerk is selected",() =>{
2
backofficeCreateDeleteClerkPage.localShopClerkcheckbox().should('have.attr','aria-checked',true)
3
4
})
5
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.
JavaScript
1
4
1
backofficeCreateDeleteClerkPage
2
.localShopClerkcheckbox()
3
.should('have.attr', 'aria-checked', 'true')
4