aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2017-01-14 16:20:50 +0100
committerPetter Reinholdtsen <pere@hungry.com>2017-01-14 16:20:50 +0100
commitc87a4164115cf649a9009dd87b2774fd9f5b483a (patch)
tree14bbaeafb33bf88518054e2f217775e021fa9435
parente43e8398f6bb1af367603ebef36dc83eae5688c4 (diff)
Wait some seconds for a page to 'settle' before saving the HAR data to get more complete information.
-rw-r--r--netsniff.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/netsniff.js b/netsniff.js
index 35e5c14..86a9fcb 100644
--- a/netsniff.js
+++ b/netsniff.js
@@ -138,13 +138,15 @@ if (system.args.length === 1) {
console.log('FAIL to load the address');
phantom.exit(1);
} else {
- page.endTime = new Date();
- page.title = page.evaluate(function () {
- return document.title;
- });
- har = createHAR(page.address, page.title, page.startTime, page.resources);
- console.log(JSON.stringify(har, undefined, 4));
- phantom.exit();
+ setTimeout(function() { // Save 3 seconds later, to give javascript code some time to run
+ page.endTime = new Date();
+ page.title = page.evaluate(function () {
+ return document.title;
+ });
+ har = createHAR(page.address, page.title, page.startTime, page.resources);
+ console.log(JSON.stringify(har, undefined, 4));
+ phantom.exit();
+ },10000);
}
});
// Avoid error strings before the JSON string.