Introduction to HAR File

An HTTP Archive, or HAR file format contains flexible and extensible codes. A HAR file contains many ready made information which may be directly used to infer information which may be used by the Gatling to get a graphical representation after simulation.

The HAR file is also a way of creating scenario instead to a Scala script, as we have seen and discussed in our early topics.

The use of HAR file as a scenario is not that popular as compared to the use of Scala Script, as in the case of using of the Scala script, the user need not to think about the intermediate file which is .scala in our case. The user may simply keep on simulating the test cases and get the .html file and get the graphical output.

The HAR file can be expected to have the following details inside it:

  • How much time has been taken to fetch the DNS information
  • How much time it requires for any object to be requested.
  • How much it has taken to connect to the server
  • How much time does it take to get the assets transferred form the server to the requested object

It may be mentioned that extracting the understandable data from the HAR file is not easy directly, as it is stored as JSON code in a very low level data. But trying to analyze the data, with certain time, a person may easily get used with it.

A HAR file can be very useful to get the core parameters which are required to analyze the performance of a web application. This has to be mentioned that this file already contains the parameters in a ready-made way,so it becomes easy for the Gatling Process to acquire data out of it.

Previously, we have seen how we created scenario using the Gatling Recorder. It was a single software process and no more intermediate files were needed. The .scala file was created directed by the Gatling software itself by analyzing the live request inside the website.

Here, we will see how the requests and the total scenario is recorded by our browser itself and how we can get the ready-made .har file from our browser.

Generate and Convert HAR file

Below we will list several steps for getting the HAR file form our browser. Here, in our study we will use Mozilla Firefox as our testing browser, you may use any other browser, as almost all have the option for inspection of elements inside the browser itself.

How to see the HTTP Archive:

For this all you have to do is to go to the browser where you have already set the network proxy manual. And port 8000, host localhost and subnet mask 127.0.0.1 is already set. For all the lan settings, you may refer to our section creating test scenario.

Now go to the browser and right click and select the inspect element option. gatling-inspect-element After clicking into inspect element, you should see the following screen: gatling-inspect-element-network

After that browse the website you want to. In this example, we have considered india.com, you may choose any. When the page is being loaded, we should be able to see the logs being generated.

gatling-save-har You may choose to save your harfile inside any folder you want. Now it is time to convert the har file into scala script.

Converting the HAR into Scala:

For this you have to start the Gatling recorder, then open file recorder.bat, and you should see the GUI of the Gatling recorder popping up on the screen. There set your output folder, class name set as any_name, and select the har file you saved just now form the browser.

Select Recorder Mode as HAR Converter. It is shown in the screen below: gatling-har-convert

Now the start button can be tapped to start converting the HAR into required scala script. Now this script can be used to perform simulations as discussed earlier.

Advantages of HAR file

From the Gatling's simulation's point of view, there are some benefits of using the HAR file.

  • The HAR file in directly exported by the browser itself, and so there is no modification of any intermediate software between.
  • The file contains almost all the ready-made information about the web pages and so it becomes easier for the Gatling, to process them.
  • Decreases the load of the Gatling Recorder.
  • As exported in JSON code, it may be used by other software to produce different file format outputs, instead of scala only.
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Protractor Training

new tutorial I am starting new Protractor training batch on Weekends. Course starts from 08-june-2019 [10am IST to 1 pm IST] based on online for 6 days, and course fee is INR 10, 000.

Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224

Find the course content : View Content