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

77
Views
Método Cypress para elegir una sección if dependiendo de una cadena

¿Cómo puedo escribir este método correctamente en Cypress para que cuando llamo, por ejemplo, a setToOffService('Online booking') sepa cómo ir al si correcto y llamar a la identificación apropiada para esa cadena?

Espero haber proporcionado todos los detalles importantes.

 setToOffService(name: string) : void { cy.get('#Service_IsActive').then(($name) => { if ($name.text().includes('Service is available')) { cy.get('#Service_IsActive').click({force:true}); } else if ($name.text().includes('Online booking')) { cy.get('#Service_AllowOnlineScheduling').click({force:true}); } }) }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes hacer algo como esto:

 cy.get('#Service_IsActive').then(($ele) => { if ($ele.text().trim() == name) { cy.get('#Service_IsActive').click({force: true}) } else if ($ele.text().trim() == name) { cy.get('#Service_AllowOnlineScheduling').click({force: true}) } })
about 4 years ago · Juan Pablo Isaza Report

0

¿Parece que el parámetro de name debería controlar en qué elemento hacer clic?

 setToOffService(name: string) : void { if (name === 'Service is available') { cy.get('#Service_IsActive').click(); } if (name === 'Online booking') { cy.get('#Service_AllowOnlineScheduling').click(); } } setToOffService('Service is available') // clicks #Service_IsActive setToOffService('Online booking') // clicks #Service_AllowOnlineScheduling
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!