Problem:
- How to update the parameter value taken from the CSV file at each occurrence in an iteration in JMeter?
Or - How to pass a new value of a parameter fetched from the CSV file in the same iteration in JMeter?
Explanation:
When a new iteration starts in JMeter then a value gets assigned to the parameter from the CSV file (when CSV Data Set Config is used for test data). This assigned value remains the same across the iteration. But in some scenarios, a new value of the parameter needs to be passed at each occurrence of the parameter within the same iteration.
Note: LoadRunner has an option “Each Occurrence” under the “Update Value On” attribute in the Parameter List. This option helps to update the value every time when the parameter appears in the script within the same iteration.
Solution:
Add the same CSV Data Set Config element as a child of the request where the next parameter value needs to be passed. This child element will fetch the next value present in the CSV file.
Example:
A CSV file contains below values:
perfValue01
perfValue02
perfValue03
perfValue04
perfValue05
Consider, there are 2 more occurrences of the same parameter in an iteration. Each occurrence of the parameter (in Request 3 and Request 4) should have a new value from the CSV file. Refer to the screenshot:
See the result:
Important Point:
If samplers (requests) are in the same transaction controller then JMeter will not update the parameter value and pass the same value in each occurrence. Hence it is recommended to add the samplers in a separate transaction controller.
You may be interested:
- Parameter Setting: Unique Each Occurrence
- Parameter Setting: Sequential Each Occurrence
- Parameter Setting: Random Each Occurrence
Hi Ace,
In my knowledge, there is no such method or plugin which can simulate this scenario.
use “Sharing Mode” = “Current Thread”
Hi Gautam,
This is fine, but even using this setting, the parameter value will be same within the iteration.
Correct, because in the same line; value does not get updated.
Sequential Each Occurrence in same request: https://www.youtube.com/watch?v=W3nagpYyXQ8&t
Random and Unique Each Occurrence in same request: https://www.youtube.com/watch?v=x97uFKXceyE&t
Follow this link- https://www.perfmatrix.com/jmeter-parameter-setting-unique-each-occurrence/