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

266
Views
Obtener webElementId como 'indefinido' en Nightwatch
module.exports = { 'TESTTT'(browser){ browser .url ("https://xyz") .elements('xpath', '//div[@class="ant-card-head-title"]//span', function (elements) { console.log(elements.value) // It prints all the three web elements elements.value.forEach(function (elementsObj) { console.log("WebElementID: " + elementsObj.ELEMENT) // gives undefined browser.elementIdText(elementsObj.ELEMENT, function (result) { console.log('\n' + result.value) }) }) }) } }

Estoy usando Nightwatch para la automatización de la interfaz de usuario. Hay tres elementos Web cuyo texto quiero imprimir. Antes del ciclo ForEach cuando imprimo ( elements.value ) me da los tres elementos. Pero cuando imprimo después de ForEach , da un valor ' undefined ' de un webElementId . ¿Por qué está dando un valor indefinido?

Captura de pantalla de error

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

ingrese la descripción de la imagen aquí

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

0

No estoy seguro de qué se supone que es .ELEMENT. si está utilizando vscode y no puede presionar strg + hacer clic en ELEMENTO, entonces no existe.

Si desea obtener el valor del objeto, pruebe mi código modificado. Esto funciona para mi ;)

 module.exports = { 'TESTTT'(browser){ browser .url ("https://xyz") .elements('xpath', '//div[@class="ant-card-head-title"]//span', function (elements) { console.log(elements.value) // It prints all the three web elements elements.value.forEach(function (elementsObj) { // Changed Code below let elementID = elementsObj[Object.keys(elementsObj)[0]] console.log(`WebElementID: ${elementID}`) // Logs the first property value of the elementsObj browser.elementIdText(elementID, function (result) { // Changed Code above console.log('\n' + result.value) }) }) }) } }
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!