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

221
Visualizações
Output execution time for a Playwright step with AJAX payload

I am trying to dump out a few key measurements to console when my test runs, rather than getting them from the reporter output, but I can't see how to grab the time taken for the last step to execute. Here's a simplified version based on the docs for request.timing() but I don't think that what I'm doing is classed as a request:

const { test, expect } = require('@playwright/test');

test('ApplicationLoadTime', async ({ page }) => {

  // Wait for applications to load
  await page.waitForSelector('img[alt="Application"]');

  // Not working! - get time for step execution
  const [fir] = await Promise.all([
    page.click('text=Further information requested'),
    page.waitForSelector('img[alt="Application"]')
  ]);
  console.log(fir.timing());

});

The click on "Further information requested" causes the page to be modified based on an AJAX call in the background and the appearance of the Application img tells me it's finished. Is this possible or do I need to rely on the reports instead?

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

0

fir is going to be undefined in your code as page.click() doesn't return anything. You need to wait for the request whose timing you're interested in, use page.waitForEvent('requestfinished') or waitForNavigation:

const { test, expect } = require('@playwright/test');

test('ApplicationLoadTime', async ({ page }) => {

  // Wait for applications to load
  await page.waitForSelector('img[alt="Application"]');

  const [fir] = await Promise.all([
    // Wait for the request
    page.waitForEvent('requestfinished', r => r.url() == '<url of interest>'),
    page.click('text=Further information requested'),
    page.waitForSelector('img[alt="Application"]')
  ]);
  console.log(fir.timing());

});
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