Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda