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.
HAR file can be expected to have the following details inside it:
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.
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.
For this all you have to do is to go to the browser where you have already set the network proxy manual. And port
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. After clicking into inspect element, you should see the following screen:
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.
You may choose to save your
harfile inside any folder you want. Now it is time to convert the
har file into
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:
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.
From the Gatling's simulation's point of view, there are some benefits of using the HAR file.
JSONcode, it may be used by other software to produce different file format outputs, instead of