HAR Export Trigger
HAR Export Trigger is Firefox add-on improving the way how HAR (HTTP Archive) export of collected data from the Network panel can be automated. This add-on is built on top of native developer tools in Firefox. Firebug is not needed for this add-on.
Basic automated HAR export is already supported by Firefox 41+ and all the user needs to do is set devtools.netmonitor.har.enableAutoExportToFile
preference to enable it. As soon as this pref is true, a new HAR file is created automatically for every loaded page and stored in <your-firefox-profile-dir>/har/logs
directory.
The developer Toolbox needs to be opened for this built-in feature to work.
Note that manual HAR export is also supported since Firefox 41. Just select the Network panel (make sure there are some collected data) and pick either Copy All As HAR (into the clipboard) or Save All As HAR (into a file).
While this basic support might be enough for most users there are also complex systems requiring more flexibility. It's sometimes necessary to execute HAR export more than once during page life time (not only after the page is loaded) - e.g. to measure HTTP traffic after specific user action. Some systems might need to send HAR directly to remote server (not save it locally as a file). Another systems might want to process HAR data before it's actually stored as a file, etc.
All such things can be done on top of the HAR Export Trigger that exports HAR API directly to the page. Any automated system can be consequently built on top of the API and trigger HAR export using a simple JavaScript call at any time. It can be also nicely integrated with e.g. Selenium to implement automated HAR export robots for existing automated test suites.
Read more about HAR format (based on JSON).
Report issues or suggestions
Requirements
You need Firefox 42+ to run this extension.
Download
See the latest release
How To Use
This extension exposes HAR API into the content allowing pages to trigger
HAR export as needed. To ensure that API is properly exposed into the
page content you need to set the following preference
in your Firefox profile (any string value passed later into API calls):
extensions.netmonitor.har.contentAPIToken
To start automated collecting of HTTP data you need to set
the following preference:
devtools.netmonitor.har.enableAutoExportToFile
You might also want to also set the following preference to true, so the developer Toolbox doesn't have to be opened.
extensions.netmonitor.har.autoConnect
The script on your page can look like as follows:
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
title: "my custom title", // Title used for the HAR file
jsonp: false, // Set to true if you want HARP
fileName: "my test har file %Y, %H:%M:%S" // Name of the file
};
HAR.triggerExport(options).then(result => {
console.log(result.data);
});
Check out a test page
Examples
You might want to checkout more HAR API examples.
Prefereces
See a list of all available preferences that you can set and modify the way how HAR data are exported. Preference values can be changed through about:config
URL in Firefox.
devtools.netmonitor.har.compress
If set to true the final HAR file is zipped. This might represents great disk-space optimization especially if HTTP response bodies are included.devtools.netmonitor.har.defaultFileName
Default name of the target HAR file. The default file name supports formattersdevtools.netmonitor.har.defaultLogDir
Default log directory for generate HAR files. If empty all automatically generated HAR files are stored in/har/logs devtools.netmonitor.har.enableAutoExportToFile
If true, a new HAR file is created for every loaded page automatically.devtools.netmonitor.har.forceExport
The result HAR file is created even if there are no HTTP requests.devtools.netmonitor.har.includeResponseBodies
If set to true, HTTP response bodies are also included in the HAR file (can produce significantly bigger amount of data).devtools.netmonitor.har.jsonp
If set to true the export format is HARP (support for JSONP syntax that is easily transferable cross domains)devtools.netmonitor.har.jsonpCallback
Default name of JSONP callback (used for HARP format)devtools.netmonitor.har.pageLoadedTimeout
Amount of time [ms] the auto-exporter should wait after the last finished request before exporting the HAR file.extensions.netmonitor.har.contentAPIToken
(introduced by HAR Trigger Export) API token that needs to be passed into all HAR API calls to verify the user.extensions.netmonitor.har.enableAutomation
(introduced by HAR Trigger Export) Enable the automation without having a new HAR file created for every loaded page. This is useful primarily for HAR API consumers.
License
HAR Export Trigger is free and open source software distributed under the
BSD License.
Resources
- HAR 1.2 Format Spec: http://www.softwareishard.com/blog/har-12-spec/
- HAR Discussion Group: http://groups.google.com/group/http-archive-specification
- HTTP Archive Viewer: http://www.softwareishard.com/blog/har-viewer/
- HAR Export Trigger Source: https://github.com/firebug/har-export-trigger