2

I have a post request which looks like this { "action": "CN", "contract": "138484833", "company": "B", "job_number": 1234564, "timestamp": 2020121710470000 } similarly I have 10 rows with above request only the values changes, I need to loop through all the ten record from csv and execute it in Jmeter.

I tried using Beanshell preprocessor, is there any other way to do it.

1 Answer 1

4

If you have a CSV file which looks like:

enter image description here

Textual representation:

action,contract,company,job_number,timestamp
CN,138484833,B,1234564,2020121710470000
DN,138484834,C,1234565,2020121710480000
EN,138484835,D,1234566,2020121710490000

You can build your request using the data from the file as follows:

  1. Add CSV Data Set Config as a child of the request you want to parameterize

  2. Configure it as follows:

    enter image description here

  3. In the "Body data" tab of the HTTP Request sampler use the following syntax:

    {
      "action": "${action}",
      "contract": "${contract}",
      "company": "${company}",
      "job_number": ${job_number},
      "timestamp": ${timestamp}
    }
    

    enter image description here

  4. That's it, each virtual user will read the next row from the CSV file on each iteration and substitute JMeter Variables placeholders with the real values from the CSV file

    enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

It only executes the first record of the csv file. and moreover i also need to know how can i dynamically change the value of my variable which should take the value from the resultant variable.
Thank you, I added ${__javaScript("${var1}"!="",)} in while controller and defined var1 in csv config it worked.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.