0

I just started using Jmeter and don't know how to make a variable. This is the HTTP body request and I would like to change the project name each time I perform load testing. body data

I tried using CSV config but it didn't work.

2 Answers 2

0

If you have a CSV file which looks like

project x
project y
project z
  1. Add a CSV Data Set Config and:

    • provide full or relative path to the CSV file, i.e. projects.csv
    • desired variable name, i.e. project

    enter image description here

  2. Once done you will be able to refer the value from the CSV as ${project} where required, i.e. in the Body Data tab of the HTTP Request sampler

    enter image description here

  3. When you run your test the ${project} JMeter Variable placeholder will be replaced by the next line from the CSV file on each iteration of each virtual user:

    enter image description here

More information: JMeter Parameterization: The Complete Guide

0

You can parametrize the body in JMeter by using the following steps:

1 Add a "HTTP Request" sampler to your test plan

2 In the Body Data section of the HTTP Request sampler, use variables to define the content of the request body. For example, if you want to send a JSON payload, you can write it like this:

{
   "username":"${username}",
   "password":"${password}"
}

3 To define the values of the variables, you can use a "CSV Data Set Config" element.

4 In the CSV Data Set Config element, specify the file name and other details of the CSV file containing the data.

5 Reference the variables in the HTTP Request sampler using the syntax ${variable_name}

For more detailed information, you can refer to the following resources:

  1. JMeter User Manual - https://jmeter.apache.org/usermanual/index.html
  2. JMeter - How to Use CSV Data Set Config - https://jmeter.apache.org/usermanual/component_reference.html#CSV_Data_Set_Config
  3. How to Parameterize Requests in JMeter - https://www.blazemeter.com/blog/how-to-parameterize-requests-in-jmeter/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.