Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
Nightwatch JS | Getting Next Sibling Text

I am attempting to write a function that can acquire the text value of a nextSibling node underneath a label bracket. I need to be able to put that text into a global variable that I can reference later in the test, but my current function, while it is retrieving the webElementId, is not retrieving the text. Instead, my console.log function is outputting a blank value.

To give some context on the code in question, here is the HTML layout of the field I am attempting to parse.

<iframe> id=[some_id]
  #document
    <html>
      <head>
        <body>
          <div> id=[some_id]
            <form> id=[some_id]
              <div> id=[some_id]
                <div> id=[some_id]
                  <div> style=[some_style]
                    <label>[some text]<label>
                      [text field in question]

That's just the basic layout, but here is the code snippet that I am attempting to use to grab the sibling node, get the id, and then get the text of the webElementId.

.getNextSibling('div[id=popover_content] > form[id=perform_sub_task_form] > div[id=perform_task] > div[id=dialog_container] > div > label:nth-of-type(8)', function(dateObj) {
  let dateVal = dateObj.value.getId()
    console.log(`datevalue: ${dateVal}`)
    browser.elementIdText(`${dateVal}`, function(result) {
      console.log('\n' + result.value)
      initial_date = result.value
})
 })

I have already attempted to simplify this and run a callback function on just the .getNextSibling function using result.value.getText(), that just results in Nightwatch telling me that the function doesn't exist. Reading the documentation for the getNextSibling() function, I found that getId() can be added onto the callback, so I decided to use that to my advantage and attempt to use the provided webElementId and write the snippet above.

I know that my code works up to the first console.lg function, because the webElementId is successfully rendered in the terminal I'm running off of. But once it tries to log the result.value, a blank line appears in the terminal.

My question is, how can I edit this snippet above so that it stops giving me a blank value? Is there an issue with my browser.elementIdText() function?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda