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

186
Visualizações
How to pause the test script for 3 seconds before continue running it? Playwright

I'm running a test called create admin. The test will first create admin, then check if the admin was created successfully.

In the script, I have a part of code where I want to wait for 3 seconds before continuing because whenever the submit button was clicked, the website will need to take 3s to refresh the admin table (list of user info) after navigation was done. For more information, this refresh is not a navigation and therefore, my 'waitForNavigation()' is not working.

Therefore, the process will be like: 'fill out the form' > 'click submit button' > 'wait for navigation' > 'reload user table (3s).

If I don't wait 3s for the table to refresh, the test will throw an error because the registered user will not be found in the table (I have other scripts to find the user).

This is how the navigation looks like when 'Save button' was clicked: enter image description here

After that, the table takes 3s to refresh and it looks like: enter image description here

This is how the 'create' function looks like: enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can wrap setTimeout as Promise and use it inside async functions:

const delay = ms => new Promise(resolve => setTimeout(resolve, ms))

where ms - delay in millisceonds you wanna wait.

Usage in your code:

...
await page.click('button :text-is("Save")');
await delay(3000); // <-- here we wait 3s
return username;
about 4 years ago · Juan Pablo Isaza Relatório

0

Use setTimeout to do that. Here's an example

function  delayedCheck() {
  const processComplete = true; // set the right boolean here

  if ( processComplete ) {
    // Do something
  } else {
    setTimeout(delayedCheck, 3000); // try again in 3 seconds
  }
}

delayedCheck();
about 4 years ago · Juan Pablo Isaza Relatório
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