1

I have a Loop controller and inside i have a http request and payload . PayloadBody Looks like below.

{
"id"="12345"
}

In the counter if i have 3 it should be 12346,12347 I need to increase value of a variable each time when iterates. i used the below JSR223 script as below

int counter=(vars.get('ContactId') as int) +1
vars.put('counter',counter as String)
log.info(vars.get('counter'))

it's taking next digit but same value in the counter it's not increasing as +1.

1 Answer 1

2

The easiest solution is changing your 12345 part to __intSum() and __counter() functions combination, i.e. something like:

{
"id"="${__intSum(12345,${__counter(,)},)}"
}

This way you will get an incremented number each time the request is sent

enter image description here

More information: How to Use a Counter in a JMeter Test

1
  • Thanks for the above solution. I'm trying with Aplhanumeric incremet like BA1234,BA1235 ..etc .inside a same loop. it's not accepting.I tried with the counter placing a reference variable. but no luck Oct 18, 2021 at 12:12

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.