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

130
Views
Vuelva a intentar la declaración if hasta que se encuentre el elemento 'Retirado' en Cypress
cy.get('body').then(($body) => { if ($body.text().includes('Withdrawn')) { cy.contains('Withdrawn') .click({force:true}) } else if ($body.text().includes('More')) { cy.contains('More') .click({force:true}) cy.wait(10000) cy.contains('Withdrawn') .click({force:true}) })

Hola, soy nuevo en cypress y deseo repetir la declaración if nuevamente hasta que se encuentre el elemento 'Retirado' en el cuerpo haciendo clic en el botón más. ¿Alguien puede decirme cuál es la mejor manera de ejecutar esto?

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

0

No estoy seguro de si este es precisamente el código correcto, pero la idea es llamar recursivamente al código que tiene para una sola iteración.

 const clickUntilWithdrawn = ($parent, attempts = 0) => { if (attempts > 10) throw 'Failed to find' if ($parent.text().includes('Withdrawn')) { cy.contains('Withdrawn').click() return } cy.contains('More').should('be.visible').click() cy.wait(10000) // probably can be shorter wait with visibility check above clickUntilWithdrawn($parent, ++attempts) } cy.get('parent-element-of-withdrawn') .then($el => clickUntilWithdrawn($el))
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!