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?
asked Feb 28, 2018 at 6:01

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

answered Feb 28, 2018 at 8:31
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! Commented Mar 1, 2018 at 6:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.