How can i check that this button is disabled:
<button _ngcontent-c8="" class="customButton" testid="save-button" type="submit"><span _ngcontent-c8="" class="textButtonForm"> Sauver </span></button>
I have tested:
cy.getBySel('save-button').should('have.attr', 'disabled')
Even tested:
cy.getBySel('save-button').should('be.disabled')
i have the error:
expected <button.customButton.formNotChanged> to have attribute disabled
Any advice pls?
If that is how the element looks at runtime, you can just add the square brackets to make it work.
cy.getBySel('save-button').should('have.attr', '[disabled]')
However, I think you are showing the source code not the runtime HTML.
This [disabled]="myFormForm.invalid" says whenever the form is invalid, add the disabled attribute.
So, in your test you need to cause the form to be invalid. Then both test examples you gave will work.
Look at the other fields in the form and see what validations are set up. The simplest would be a required validation - make sure that element is empty.