Introduction to the Gatling Recorder

Learn Gatling concepts and use the Recorder to create a runnable Gatling simulation.

Introduction

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.

  1. The user arrives at the application.
  2. The user clicks on the login button.
  3. The user goes to the login page.
  4. The user logs in.
  5. The user adds the first product to his cart.

Clone Gatling demo repository

  1. Clone the sample project repository.

  2. Open the project in your IDE or terminal.

  3. 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.

  1. Enter a ‘Homepage’ tag in the Recorder application and click Add.
  2. Go to the website: https://ecomm.gatling.io.
  3. Return to the Recorder application.
  4. Enter a ‘Authentication’ tag and click Add.
  5. Click on the ‘Login’ button in the top right.
  6. Click on ‘Submit’.
  7. Return to the Recorder application.
  8. Enter a ‘Cart’ tag and click Add.
  9. 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

  1. 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
    
  2. The above command will create a packaged jar file in your project’s target directory.

  3. 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.

  4. Go to Simulations > Create a simulation > Test as code. Under Select a package, choose the newly created package, then click Create.

  5. 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:

  1. Generate an API token with the Configure permission in your Gatling Enterprise account.

  2. 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>
    
  3. 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:

  1. Run the following command:

    Maven:

       
    ./mvnw gatling:test
    
    mvnw.cmd gatling:test
    

    JavaScript CLI:

    npx gatling run --simulation basicSimulation
    
  2. 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.

Edit this page on GitHub