Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
Decision for a button by input value in cypress

I have the following code, which is responsible for the state of a checkbox slider (on/off).

When the button is on:

      <div _ngcontent-ofr-c662="" class="pull-right switch switch-small">
       <div _ngcontent-ofr-c662="" class="col-auto"><label _ngcontent-ofr-c662="" class="o-switch">
<input _ngcontent-ofr-c662="" type="checkbox" ng-reflect-model="true" ng-reflect-is-disabled="false" ng-reflect-options="[object Object]" class="ng-untouched ng-valid ng-dirty"><span _ngcontent-ofr-c662="" data-off="No" data-on="Yes" class="switch__obj"></span></label></div>
       <label _ngcontent-ofr-c662="" for="chkAllowCancelOrReschedule"></label>
    </div>

And when the button is off:

 <div _ngcontent-ofr-c662="" class="pull-right switch switch-small">
       <div _ngcontent-ofr-c662="" class="col-auto"><label _ngcontent-ofr-c662="" class="o-switch">
<input _ngcontent-ofr-c662="" type="checkbox" ng-reflect-model="false" ng-reflect-is-disabled="false" ng-reflect-options="[object Object]" class="ng-untouched ng-valid ng-dirty"><span _ngcontent-ofr-c662="" data-off="No" data-on="Yes" class="switch__obj"></span></label></div>
       <label _ngcontent-ofr-c662="" for="chkAllowCancelOrReschedule"></label>
    </div>

The only state that changes is that of the variable ng-reflect-model

How can I check this status and if it is true, press that button, and if it is off nothing happens and the test continues?

I hope I put all the details and didn't miss something.

Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Look at the value of the attribute using jQuery .attr(), like this

cy.get('input').then($el => {
  if ($el.attr('ng-reflect-model') === 'false') {
    cy.wrap($el).check()
  }
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda