Example - Recorder
Learn how to use the Gatling recorder and generate Gatling test scripts.
We'll cover the following
In the previous lesson, we learned how to set up the Gatling recorder and change the proxy setting to route the requests to the Gatling recorder before hitting the actual server.
In this example, we will learn how to record Google search on a browser and generate Gatling scripts.
Understanding the available configurations
In the below image, we see several configurations and settings. Let’s see what we can use them for:
- Listening port – the proxy server’s host and port that will be created by Gatling to route all the requests from the browser.
- Class Name – the Scala class that will be created at the end of the recording, which is the Gatling test script. We can also mention the Package name along with the Class Name. Package is an optional field.
- Simulation Folder – the location where the generated Gatling test scripts will be saved.
- Filters – we can use filters to capture only a few requests that match a given whitelisted/blacklisted pattern.
- Strategy – we can choose a strategy to filter requests. It is a drop-down list that contains three options:
- Disabled
- WhiteList First
- BlackList First
- Static Resources – used to prevent capturing static resource files like images, CSS, font, JS, etc.
- Start – once all the necessary information is filled, we can start capturing requests.
Capturing requests
Once we click on the start button in the Gatling recorder, the following UI appears:
- Tag is for grouping requests.
- Clear is for clearing all the captured requests.
- Cancel is for canceling the recording that is being done.
- Stop & Save is for stopping the recording and generating Gatling test scripts for the captured requests.
We are assuming that you have done the proxy setup by following the steps given in the previous lesson. If your Gatling recorder is running, you are set up to start recording.
Now, perform the following steps:
- Open a browser of your choice (Chrome, Firefox, Safari, etc.)
- Navigate to www.google.com.
- Enter the search text - educative
As we perform the above steps on the browser, we should see the requests getting captured as shown below:
By clicking on the request under Executed Events, we should see the details about the request and its response.
Once the intended operation or sequence of operations is done, click on the Stop & Save button to generate the Gatling test script for the captured requests, and it will be placed in the location given in the simulation output folder.
Generated Gatling test script
The following is the Gatling test script that will get generated once we hit the Stop & Save button after performing the needed steps.
The User-Agent
header changes depending on the browser that the request was sent from.
Get hands-on with 1400+ tech skills courses.