0

I have requirement with increment value for each iteration and using loop controller. I tried with the _V function and __intSum(${myVar},${__counter(,)},)}. it's incrementing only for digit and not for AlphaNum . my paylody body like this.

{
"name":"BAN401"
}

I'm using like below.

{
"name":${__intSum(${FirstName},${__counter(,)},)}"
}

1 Answer 1

2
  1. Amend your body data as:

    {
    "name":"${FirstName}"
    }
    
  2. Add JSR223 PreProcessor as a child of the request which payload you need to increment

  3. Put the following code into "Script" area:

    def numericPart = (vars.get('FirstName') =~ /(\d+)/)[0][1] as int
    
    def incremented = numericPart + 1
    
    vars.put('FirstName', vars.get('FirstName').replace(numericPart as String, incremented as String))
    
  4. That's it, each time the request will be called it will send an incremented value of the ${FirstName} JMeter Variable

Demo:

enter image description here

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

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.