Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Test button is disabled

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?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

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.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!