-
Notifications
You must be signed in to change notification settings - Fork 10
Examples
Jan Odvarko edited this page Nov 4, 2015
·
10 revisions
Take a look at a few example scripts showing how to trigger HAR export on a page.
This script shows how to trigger HAR export and get JSON data back (no local file created).
var options = {
token: "test", // Value of the token in your preferences
getData: true, // True if you want to also get HAR data as a string in the callback
};
HAR.triggerExport(options).then(result => {
console.log(result.data);
});
This example shows how to trigger HAR export and save the log automatically in a local *.har
file. The default target directory is <firefox-profile-dir>/har/logs
. You can provide different directory path in devtools.netmonitor.har.defaultLogDir
preference.
File name can use format string to have better control over the formatting of the generated file name.
var options = {
token: "test",
fileName: "my test har file %Y, %H:%M:%S" // Name of the file with format string
};
HAR.triggerExport(options).then(result => {
// The local file is available now
});
It's possible to handle an har-page-ready
event that is fired when the page is ready (fully loaded). This event complements the existing DOMContenLoaded
and onLoad
. It's fired when the following conditions are true.