0

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?

1 Answer 1

1
  1. Add JSR223 PostProcessor after the Regular Expression Extractor
  2. 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)
    
  3. Replace your_var_from_regex with the Reference Name of the JMeter Variable you defined in the Regular Expression Extractor
  4. You will be able to refer concatenated, comma-separated value as ${foo} where required.

Example test plan structure:

JMeter Concatenate Variables

More information: Apache Groovy - Why and How You Should Use It

1
  • 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! Mar 1, 2018 at 6:06

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.