Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda