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

262
Views
¿Cómo eliminar el atributo "seleccionado" y moverlo a otra opción usando Cypress?

Yo he tratado:

 cy.get(`div[class="input-group input-group-sm"] select[name="activeStatus"]`).find(":selected").invoke("removeAttr", "selected")

que no funciona como esperaba, pero creo que ha sido lo más parecido a eso. ¿Alguien tiene algún consejo? Quiero mover el atributo "Seleccionado" de Activo a Cancelado.

ingrese la descripción de la imagen aquí

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

0

Estás a mitad de camino, la parte de eliminación funciona. Para agregar selected a Cancelled , invoque attr

 // remove cy.get('select') .find(':selected') .should('contain', 'Active') .invoke('removeAttr', 'selected') // add cy.get('select') .find('option') .contains('Cancelled') .invoke('attr', 'selected', true) //confirm cy.get('select') .find(':selected') .should('contain', 'Cancelled')

esto te da

 <option selected="selected">Cancelled</option>

Si tu prefieres

 <option selected>Cancelled</option>

usa esto en su lugar

 // add cy.get('select') .find('option') .contains('Cancelled') .then($el => $el[0].setAttribute('selected', ''))
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!