-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Hi, pageTimings is empty in har file, it cause I can not get onLoad time and onContendLoad time. Could you please help to have a look? Thanks in advance.
here is my script
describe("use puppeteer to get har file ", () => {
it("use more launch properties demo", async () => {
if (generate.getConfigs().isWindows) {
configs = generate.getConfigs().windows;
} else {
configs = generate.getConfigs().macOrLinux;
}
browser = await puppeteer.launch({slowMo: '1000', headless: false, executablePath: configs.chromePath,args: [--window-size=1920,1080
]});
page = await browser.newPage();
har = new PuppeteerHar(page);
await page.setViewport({width: 1920, height: 1080});
await page.setDefaultTimeout(configs.timeout)
/*
* har1
* /
await har.start({path: path.join(path.resolve(), configs.bmcReportPath.scenario1+'1.har')});
await page.goto("https://www.biomedcentral.com/");
await page.waitFor(5000)
await har.stop();
/
* har2
* */
await har.start({path: path.join(path.resolve(), configs.bmcReportPath.scenario1+'2.har')});
//get DOM element whose innertext is Search and clcik
await page.evaluate(() => {
const elements = [...document.querySelectorAll('span')];
const targetElement = elements.find(e => e.innerText == 'Search');
if (targetElement) targetElement.click();
});
await page.$eval('#publisherSearch', el => el.value = 'carbon neutral');
await page.keyboard.press('Enter');
await page.waitFor(5000)
await har.stop();
/*
*
* */
await page.close();
await browser.close();
});
});
here is my hare file with puppeteer-har tools, pageLoadTime is empty.
{
"log": {
"version": "1.2",
"creator": {
"name": "chrome-har",
"version": "0.11.12",
"comment": "https://github.com/sitespeedio/chrome-har"
},
"pages": [
{
"id": "page_1",
"startedDateTime": "2021-12-15T12:00:23.038Z",
"title": "https://www.biomedcentral.com/",
"pageTimings": {}
}
],
If I download har file manually, pageTimes is not empty. here is har file manually.
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2021-12-14T07:02:58.380Z",
"id": "page_17",
"title": "https://www.biomedcentral.com/",
"pageTimings": {
"onContentLoad": 263.5190000291914,
"onLoad": 22470.13099998003
}
}
],