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

127
Vistas
Nighwatch ignores await in tests

I'm trying to start with Nightwatch and faced the unclear behavior.

Please take a look at the the following code. I want to gather some text from a page into the list and then print it. Note the async test and await browser.perform call:

module.exports = {
    '@tags': ['smoke test'],
    'Work with a table': async browser => {
        browser.page.mainPage.tablePage().navigate();
        let list = []
        await browser
            .perform(function () {
                browser.elements('css selector', 'thead th', function (elements) {
                    elements.value.forEach(function (elementsObj, index) {
                        browser.elementIdText(elementsObj.ELEMENT, function (result) {
                            list.push(result.value)
                            console.log('>> ' + result.value);
                        })
                    })
                })
            })
        console.log('list: ' + list);
        console.log('end');
    }
}

In my understanding, I should see the result of console.log('list: ' + list) as a fulfilled list at the end of the test. But the output is:

\ Running Work with a table:
list:
| Running Work with a table:
>> Name
>> Position
>> Office
>> Age
>> Start date
‼ Running Work with a table:

No assertions ran.

So the console.log('list: ' + list); was executed before. What I'm doing wrong here?

Another one question is why the last console.log('end'); is not printed at all?

Update I tried to name the test as 'Work with a table': async function(browser), with the same result. And if I add the await keyword to the browser.page.mainPage.tablePage().navigate(); command, there is no console log printed at all.

Update2 The result of broser.perform is a Promise, enter image description here

When I print it, I get the following:

Promise {
  <pending>,
  capabilities: {
  acceptInsecureCerts: false,
  acceptSslCerts: false,
  applicationCacheEnabled: false,
  browserConnectionEnabled: false,
  . . . 
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