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

243
Views
Usando async await en Cypress

Soy muy nuevo en Cypress y estoy tratando de tomar un valor de un elemento para usarlo después en la prueba, pero no puedo obtener el valor. Alguien dijo que necesito usar async await, pero no funciona o tal vez estoy haciendo algo mal. ¡Gracias por adelantado!

 it.only('should access Time Worked section and insert same Staff Complement value, but negative as Flexitime', function () { let timeValue = 0; cy.get('[data-tag="staff-complement-input"] > div > span').invoke('text').then(text => +text).then(($val) => { // $val = 420 timeValue = $val; cy.log(timeValue) //420 }) cy.log(timeValue) // 0 // need timeValue to be 420 })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar alias y guardar el valor y usarlo más tarde.

 cy.get('[data-tag="staff-complement-input"] > div > span') .invoke("text") .then((text) => +text) .as("someNum") cy.get("@someNum").then((someNum) => { cy.log(someNum) //420 })

Un punto a recordar es que Cypress borra los alias después de cada prueba. Entonces, lo anterior solo funcionará si está haciendo todo bajo un bloque it() .

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!