Trigger HAR export any time directly from within a page.
WebExtension improving automated HAR (HTTP Archive) export of collected data from the Network panel. This extension is built on top of WebExtensions DevTools API (compatible with Firefox and Chrome).
The extension 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.
Download from AMO
Or you can also install it from source:
- Clone or download source code in this repository to your machine.
- Launch Firefox Nightly and open
about:debugging
page - Click
Load Temporary Add-on
and pick any file from the root source code directory (e.g.manifest.json
- Re-open an existing DevTools Toolbox to make sure the extension is properly loaded by Firefox DevTools.
You might also use web-ext
command line tool. Read more on MDN.
Quick description of the directory structure in this project.
src
- source filesres
- icons, styles, etc.lib
- HAR client API files
You need Firefox 61+ to run this extension.
The following Firefox bugs are related:
Bug 1311177- (fixed in Firefox 60) Implement the devtools.network.getHAR API methodBug 1311171- (fixed in Firefox 60) Implement the devtools.network.onRequestFinished API eventBug 1436665- (fixed in Firefox 61) onRequestFinished event should be sent even if the Netmonitor UI isn't initializedBug 1434855- (fixed in Firefox 60) HAR export is very slow
There are following scopes related to the architecture of this extension.
- Page scope - This is where your page is running. This scope also includes harapi.js file (see lib dir in this repo) and eg triggers HAR export.
- Content scope - This scope is responsible for handling messages from the page and communicating with the DevTools scope.
- Background scope - Background scope is responsible for relaying messages between Content and Devtools scopes.
- Devtools scope - This scope is responsible for accessing DevTools WebExtension API and sending results back to content scope.
Install the extension into your browser (Firefox & Chrome supported).
HAR API implemented in harapi.js
file is automatically injected
into your page (the file is available in lib
directory in this repo).
An example script looks like as follows:
HAR.triggerExport().then(harLog => {
console.log(harLog);
});
HAR.addRequestListener(harEntry => {
console.log("Request finished", request);
});
See also online test page.
- Test page for HARExportTrigger: http://softwareishard.com/test/harexporttrigger/
- HAR Spec: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HAR/Overview.html
- HAR Spec (original): http://www.softwareishard.com/blog/har-12-spec/
- HTTP Archive Viewer: http://www.softwareishard.com/blog/har-viewer/
- HAR Discussion Group: http://groups.google.com/group/http-archive-specification/