I have two requests:
- The first one is in a loop controller with the count as 4. I have implemented a Regular Expression Extractor for this request.
- The second request is outside loop and this consumes the value extracted via the Regular Expression Extractor reference name.
- I have given the reference name comma separated but it just takes the same value extracted from the 4th loop of the first aforementioned request.
- How can I have all four different values extracted and passed as comma separated in the second request that resides outside loop?
asked Feb 28, 2018 at 6:01
1 Answer 1
- Add JSR223 PostProcessor after the Regular Expression Extractor
Put the following code into "Script" area:
def myVar = vars.get('foo') if (myVar == null) { myVar = '' } myVar += vars.get('your_var_from_regex') + ',' vars.put('foo', myVar)
- Replace
your_var_from_regex
with the Reference Name of the JMeter Variable you defined in the Regular Expression Extractor - You will be able to refer concatenated, comma-separated value as
${foo}
where required.
Example test plan structure:
More information: Apache Groovy - Why and How You Should Use It
answered Feb 28, 2018 at 8:31
-
Dmitri Many Thanks first of all! I don't have much idea about groovy. The code you suggested gives value like: "159010153123,159010153134," whereas I want value like: "159010150780","159010150776" So I want to put "" after each value and omit the comma at the last. Please suggest!Rohan Kalia– Rohan Kalia2018年03月01日 06:06:47 +00:00Commented Mar 1, 2018 at 6:06
Explore related questions
See similar questions with these tags.