'JMeter- If and Foreach controller

I have a test data in CSV and reading data from CSV to XML request. In one of the section of this request I would like to validation written and built on fly request. For example.

CSV- col1, col2, col3, col4..... If co11 is not null do one line of code in XML(line1) if col1 and col2 is not null do two lines of code(line1 code + line2 code)

Can someone please help in getting the code/process

building XML on the fly based on the column values with condition



Solution 1:[1]

It's possible but I don't think that you can use ForEach Controller and If Controller for this because if you're iterating values from CSV you will have one value per each loop of each thread and my expectation is that you want to have all the values at once.

If my assumption is correct I would rather recommend creating the request body in JSR223 PreProcessor using Groovy language

See Creating XML chapter of Groovy documentation for more information

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitri T