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

1.2K
Views
¿Cómo verificar si el botón está activo (se puede hacer clic) en Cypress?

Quiero verificar si un botón está activo (se puede hacer clic en él) o no está activo (existe pero no se puede hacer clic en él).

Intento las siguientes afirmaciones pero parece que está mal. porque la primera afirmación siempre es verdadera y la segunda siempre es falsa, independientemente de si se puede hacer clic en el botón o no.

 cy.get('#switchdiv').should('not.be.disabled') //clickable cy.get('#switchdiv').should('be.disabled') //not clickable

el código html para el botón en cada caso:

 <button role="button" aria-disabled="false" class="styles__CTAButton-eowIhA dBjjkp switchover"></button> <button disabled="" role="button" aria-disabled="true" class="styles__CTAButton-eowIhA dBjjkp switchover"></button>

alguna ayuda . gracias

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes hacer algo como esto:

 cy.get('#Button').then(($btn) => { if ($btn.is(':disabled')) { cy.log('Button exists and is disabled!') return } else { cy.log('Button exists and is enabled!') cy.wrap($btn).click() } })
about 4 years ago · Juan Pablo Isaza Report

0

Si la respuesta de Alapan no funciona, podría intentar usar el valor aria-disabled .

 cy.get('#Button') .invoke('attr', 'aria-disabled') .then((ariaDisabled) => { // Probably helpful to also cy.log() the value cy.log(`ariaDisabled is ${ariaDisabled}`); if (ariaDisabled !== "true") { cy.log('Button exists and is disabled!') return } cy.log('Button exists and is enabled!') cy.get('#Button').click(); });
about 4 years ago · Juan Pablo Isaza 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!