0

I am struggling a bit to make use of a variable created using the Json extractor, I have extracted all the ID's from a response and want to cycle through them individually across the threads.

Thread 1 would use id_1 and thread 2 would use id_2 etc.

I have tried using a ForEach controller but it's cycling through the whole set for each thread.

Test runs like this:

  1. Generate access token
  2. Get parameters - Extract the list of ID's here.
  3. Update parameter - Pass the ID individually here per thread.

Is there a way to achieve this?

1 Answer 1

1

You won't be able to do this because as per documentation:

Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

So if you want to perform extraction using one thread and then hit everything using multiple threads you can either convert all the variables which start with id_ to JMeter Properties using the following Groovy code snippet:

vars.entrySet().each { variable ->
    if (variable.getKey().startsWith('id_')) {
        props.put(variable.getKey(), variable.getValue())
    }
}

enter image description here

and then you will be able to access the properties using __P() function like:

${__P(id_${__threadNum},)} 

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Dmitri, this has resolved my issue and will make my test much more flexible. I am new to JMeter so still learning.

Your Answer

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.