Skip to content

Created har file contents is empty. #5

@yuji38kwmt

Description

@yuji38kwmt

I want to create har file of slow-loading website.
But created har file contents is empty.
I added sleep() function after har.start() , then har file contents is not empty.

Question

  1. Why is sleep function needed?
  2. I do not want to specify milliseconds for sleep function. What function do I use ?
    For example, should I use await page.waitForNavigation({ waitUntil: 'networkidle2' }); ?
    HAR details in file or jSON  puppeteer/puppeteer#1916 (comment)
{"log":{"version":"1.2","creator":{"name":"chrome-har","version":"0.4.1","comment":"https://github.com/sitespeedio/chrome-har"},"pages":[],"entries":[]}}
const puppeteer = require('puppeteer');
const PuppeteerHar = require('puppeteer-har');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  const har = new PuppeteerHar(page);
  await har.start({ path: 'results.har' });
  
  // Added
  await sleep(2000);

  await page.goto('http://example.slowly.com');

  await har.stop();
  await browser.close();
})();


function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions