Introduction to the Gatling Recorder
Learn Gatling concepts and use the Recorder to create a runnable Gatling simulation.
Introduction
3.13.5
and later.The Gatling Recorder allows you to capture browser-based actions to create a realistic user scenario for load testing. The Recorder application is launched from Gatling, using Maven, Gradle, sbt or the JavaScript CLI.
In this tutorial, we use Gatling to load test a simple cloud-hosted web server and introduce you to the basic elements of the Recorder. We strongly recommend completing one of the following introductory guides according to your language of preference before starting to work with the Recorder:
This tutorial showcases the Gatling recorder using two options: Java SDK with the Maven plugin and the JavaScript SDK with JavaScript CLI.
Plan the user scenario
This tutorial uses a sample e-commerce website, which is deployed at the URL: https://ecomm.gatling.io. This application is for demonstration purposes and is read-only. Please be kind and only run small proof of concept load tests against the site.
To test the performance of the e-commerce application, create scenarios representative of what happens when users navigate the site.
The following is an example of what a real user might do with the application.
- The user arrives at the application.
- The user clicks on the login button.
- The user goes to the login page.
- The user logs in.
- The user adds the first product to his cart.
Clone Gatling demo repository
Sample project prerequisites
- For Java: Java 17 or 21 64-bit OpenJDK LTS (Long Term Support) version installed on your local machine. The sample project leverages features introduced in Java 17, making it the minimum required version. We recommend the Azul JDK.
- For JavaScript: Node.js v18 or later (LTS versions only) and npm v8 or later.
Gatling SDK prerequisites
- For Java: Java 11, 17 or 21 64-bit OpenJDK LTS (Long Term Support) version installed on your local machine. While the sample project requires Java 17, The Gatling SDK support extends back to Java 11. We recommend the Azul JDK.
- For JavaScript: Node.js v18 or later (LTS versions only) and npm v8 or later.
Additionally, the tutorial uses the Mozilla FireFox browser to create the Gatling Script and Gatling Enterprise to run tests with dedicated load generators and enhanced data reporting features. Kindly check the following prerequisites:
-
Clone the sample project repository.
-
Open the project in your IDE or terminal.
-
For Java, navigate to
/java/maven
. For JavaScript, navigate go to/javascript
.
Launch the Recorder
Launch the recorder using the following command:
Maven:
./mvnw gatling:recorder
mvnw.cmd gatling:recorder
JavaScript CLI:
npm run recorder
Once launched, the Recorder application opens, allowing you to configure the settings before recording a web browser session.
Set it up with the following options:
- Recorder Mode set to HTTP Proxy
- computerdatabase package
- RecordedSimulation name
- Follow Redirects? checked
- Infer HTML resources? checked
- Automatic Referers? checked
- Remove cache headers? checked
- No static resources clicked
- Select the desired
format
. This tutorial assumes “Java 17”
After configuring the recorder, all you have to do is click Start!.
Record a website session
Once the Recorder is launched, there are 4 buttons to control the session recording:
- Add - adds a tag to organize actions in your session.
- Clear - clears the Executed events.
- Cancel - cancels the Recorder session.
- Stop & Save - stops and saves the current Recorder session.
Based on the scenario described in Launch the Recorder perform the following actions in your configured web browser. Try to act as a real user would, don’t immediately jump from one page to another without taking the time to read. This makes your scenario similar to how a real user would behave.
- Enter a ‘Homepage’ tag in the Recorder application and click Add.
- Go to the website: https://ecomm.gatling.io.
- Return to the Recorder application.
- Enter a ‘Authentication’ tag and click Add.
- Click on the ‘Login’ button in the top right.
- Click on ‘Submit’.
- Return to the Recorder application.
- Enter a ‘Cart’ tag and click Add.
- Click on ‘Add to cart’ for the ‘Pink Throwback Hip Bag’ product.
The simulation is generated in the folder:
src/test/java/
src/
Test execution
Run the Simulation on Gatling Enterprise
You can package, deploy, and run your simulation using one of two approaches, depending on whether you prefer a manual or automated process.
Simple Manual Use Case
-
Manually generate the package by executing the following command locally on your developer’s workstation:
Maven:
./mvnw gatling:enterprisePackage
mvnw.cmd gatling:enterprisePackage
JavaScript CLI:
npx gatling enterprise-package
-
The above command will create a packaged jar file in your project’s target directory.
-
From your Gatling Enterprise console, go to Packages. Create a new package specifying its name, team that owns it, select your packaged jar file for upload then click Save.
-
Go to Simulations > Create a simulation > Test as code. Under Select a package, choose the newly created package, then click Create.
-
Configure your simulation parameters:
- Simulation name.
- Under Select your package and simulation > Simulation, select your simulation class.
- Under Configure your locations, choose the Managed type and select a location based on your preference.
- Click Save and launch.
Advanced Use Case with Automated Deployments (Configuration-as-Code)
Gatling Enterprise is a feature-rich SaaS platform that is designed for teams and organizations to get the most out of load testing. With the trial account, you created in the Prerequisites section, you can upload and run your test with advanced configuration, reporting, and collaboration features.
From Gatling 3.11 packaging and running simulations on Gatling Enterprise is simplified by using configuration as code. In this tutorial, we only use the default configuration to demonstrate deploying your project. You can learn more about customizing your configuration with our configuration-as-code guide.
To deploy and run your simulation on Gatling Enterprise, use the following procedure:
-
Generate an API token with the
Configure
permission in your Gatling Enterprise account. -
Add the API token to your current terminal session by replacing
<your-API-token>
with the API token generated in step 1 and running the following command:export GATLING_ENTERPRISE_API_TOKEN=<your-API-token>
set GATLING_ENTERPRISE_API_TOKEN=<your-API-token>
-
Run one of the following two commands according to your needs:
-
To deploy your package and start the simulation, run:
Maven:
./mvnw gatling:enterpriseStart -Dgatling.enterprise.simulationName="<simulation name>"
mvnw.cmd gatling:enterpriseStart -Dgatling.enterprise.simulationName="<simulation name>"
JavaScript CLI:
npx gatling enterprise-start --enterprise-simulation="<simulation name>"
-
To deploy your package without starting a run:
Maven:
./mvnw gatling:enterpriseDeploy
mvnw.cmd gatling:enterpriseDeploy
JavaScript CLI:
npx gatling enterprise-deploy
-
Watch the Simulation deploy automatically and generate real-time reports.
Run the Simulation locally for debugging Optional
The open-source version of Gatling allows you to run simulations locally, generating load from your computer. Running a new or modified simulation locally is often useful to ensure it works before launching it on Gatling Enterprise. Using the Java SDK, you can launch your test in interactive mode using the following approach:
-
Run the following command:
Maven:
./mvnw gatling:test
mvnw.cmd gatling:test
JavaScript CLI:
npx gatling run --simulation basicSimulation
-
Choose
example.<recorded-simulation-name>
.
When the test has finished, there is an HTML link in the terminal that you can use to access the static report.
Keep learning
Now that you have completed the Introduction to scripting and Introduction to the Recorder tutorials, you have a solid foundation of Gatling and load testing knowlege. We strongly recommend you complete the Writing realistic tests tutorial to learn the essential skills for writing clean and concise tests.