Generating HAR File – HAR file is a file format used by several HTTP session tools to export the captured data. The format of this file is basically a JSON object with a particular field distribution. In any case, keep in mind that not all the fields are mandatory, and many times some information won’t be saved to the file.
HAR files can contain sensitive data like:
- content of the pages that you downloaded while recording
- cookies data, which will allow anyone with the HAR file to impersonate your account
- all the sensitive information that you submitted while recording: personal details, passwords, credit card numbers
Generating HAR file
In any case you can get a capture of a HTTP session in any of the main 3 browsers: Chrome, Firefox and IE.
How to generate HAR file in Chrome
You can record your HTTP session using the Network tab in the Developer Tools in Chrome Browser.
- Open the Developer Tools from the menu (Menu “⋮” > More Tools > Developer tools), or by pressing Ctrl+Shift+C on your keyboard
- Click on the Network tab
- Look for a round button at the top left of the Network tab. Make sure it is red. If it is grey, click it once to start recording.
- Check the box next to Preserve log
- You can use the clear button (a circle with a diagonal line through it) right before trying to reproduce the issue to remove unnecessary header information
- Reproduce the issue that you were experiencing before, while the network requests are being recorded.
- Save the capture by right-clicking on the grid and choosing “Save as HAR with Content“
How to generate HAR file in Firefox
- Start Firefox Developer Tools in Network mode (Top right menu > Developer > Network, or ctrl-shift-E)
- Reproduce the issue
- Save the capture by right-clicking on the grid and choosing “Save all as HAR“
- Export the capture to a HAR file
How to generate HAR file in Internet Explorer/Edge
Edge natively produces HAR files. See detailed instructions in the Microsoft site
- Open the Network tool in F12 developer tools
- Reproduce the issue
- Export captured traffic as a HAR (CTRL + S)
For Internet Explorer, you will need to use: HttpWatch .
- Download and Install HttpWatch
- Start the HttpWatch capture right before reproducing the behavior you want to study
- Stop the HttpWatch capture right after reproducing the behavior to study
- Export the capture to HAR format
Check out more articles here.