-
Notifications
You must be signed in to change notification settings - Fork 54
Open
Description
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
- Why is
sleep
function needed? - I do not want to specify milliseconds for
sleep
function. What function do I use ?
For example, should I useawait 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));
}
AgainPsychoX
Metadata
Metadata
Assignees
Labels
No labels