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

153
Views
Nightwatch: no se puede obtener el valor de matriz actualizado en la afirmación

Usando Nightwatch con JS. A continuación se muestra el objeto de página que estoy usando. Bajo los comandos, inicialicé una matriz vacía, "deletedPlans". Luego, más adelante en el código, le estoy agregando valores. Al final, en la afirmación, estoy tratando de imprimir el valor de matriz actualizado en el mensaje, pero no imprime nada, tomando el valor de matriz como vacío. Mientras que, dentro de la función donde he comentado, imprime perfectamente el valor de la matriz. ¿Qué mal estoy haciendo?

 module.exports = { url:'/xyz', elements: { deleteAction:{ selector: '//span[text()="Delete"]', locateStrategy: 'xpath' }, PlanTitleVerify:{ //some selector } }, commands:[{ deletePlan: async function (browser){ var myPage = this var deletedPlans =[] browser .elements('xpath', '//div[@class="ant-card-head-title"]//span', function (elements) { elements.value.forEach(element => { let key = Object.keys(element)[0]; let ElementIDvalue = element[key]; browser.elementIdText(ElementIDvalue, function (result) { let planName = result.value deletedPlans.push(planName) //Adding value to array console.log("Plan to be deleted:" + deletedPlans) //Here value gets printed myPage .pause(2000) .click('@deleteAction') }) }) }) //Here 'deletedPlans' value is printed as blank. myPage.assert.not.elementPresent('@PlanTitleVerify', 'Deleted plans are:' + deletedPlans) }, }] };

Producción:

Plan para ser eliminado: ABCD (digamos)

Los planes eliminados son:

about 4 years ago · Juan Pablo Isaza
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!