Reputation: 21
<button _ngcontent-hth-c126="" class="btn btn-secondary grid-btn m-l-12 m-r-8 p-3 warn" disabled>Edit </button>
I want to validate that element contain 'disabled' or not
how to do that in cypress
Upvotes: -1
Views: 83
Reputation: 181
You can also validate that it has the disabled attribute like this
cy.get('button').contains('Edit').should('have.attr', 'disabled')
Ref Method and Value
Also, inside the selector. This command specifies everything - both element identity and disabled condition.
cy.contains('button:disabled', 'Edit')
Upvotes: 4
Reputation: 18626
To assert that the button is disabled:
cy.contains('button', 'Edit').should('be.disabled')
To assert that the button is not disabled:
cy.contains('button', 'Edit').should('not.be.disabled')
Upvotes: 1