How to pass parameter (token) to another thread group , i need to use the parameter pass from another threadgroup as dynamic url - jmeter

How to pass parameter (token) to another thread group , i need to use the parameter pass from another threadgroup as dynamic url ( as the image above , i need to use Survey Token as parameter on the next threadgroup)
i already try some tips , but still get stucked
the token passed from the result GETSurveyToken is not successful place after /svap/survey/[token]
hope anyone can help ??
thanks
i try using : regular expression extractor, json extractor, dan using Preprocessor to get the parameter/variable

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.
What Regular Expression Extractor gives to you is a JMeter Variable so in order to be able to use it in other thread in this or other thread group you need to convert it into a JMeter Property using __setProperty() function. Once done you can access the value using __P() function
If your logic is more complex, i.e. you need to "wait" in 2nd thread group until the token is available consider using Inter-Thread Communication Plugin

Related

JMeter use variable array values individually

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:
Generate access token
Get parameters - Extract the list of ID's here.
Update parameter - Pass the ID individually here per thread.
Is there a way to achieve this?
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())
}
}
and then you will be able to access the properties using __P() function like:
${__P(id_${__threadNum},)}

Use regular expression extractor variable in Tear Down Thread Group

we have to save regular expression extractor variable in one file --> "GJC_NUMZCAISSE" Type="Integer" Value="(.+?)"/>
Data Used for StoreClosing Transaction : Closing - cbrauth,store,baid,GJC_NUMZCAISSE
GJC_NUMZCAISSE variable will fetch from Login and save into one file and use corresponded data for closing as written above.
As per JMeter 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.
Regular expression extractor produces a JMeter Variable which is visible only to the Thread Group where it's declared.
If you want to access the variable value in the tearDown Thread Group you need to convert it into a JMeter Property using __setProperty() function.
The property value can be read using __P() function where required
More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups

How to pass variable extracted using json path extractor to another thread group

I am able to extract access_token and pass it to header manager on http request in same thread group .
But I want to use this variable in other tread group also .
I am extracting json value using JSON path extractor:
Json Path Extractor
And Putting it on Header of other Same Thread Group then it work fine :
Header Manager
in 1st Thread Group use __setProperty() function to convert JMeter Variable into a JMeter Property
in 2nd Thread Group use __P() function to access the value
Demo:
More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups
There is a more "intelligent" way of sharing variables between threads/thread groups - Inter-Thread Communication plugin, check out documentation for comprehensive explanation and test plans examples.

Using Extracted JSON Value in Another JMeter Thread

First, let me preface this question that I've only been using JMeter for 36 hours.
I've been able to successfully create a thread that performs a POST (json body) to generate a new record.
{
"id":1257697771,
"displayName":"TERM2",
"functionName":"f_1257697771",
"displayableSourceExpression":"TRUE",
"typeId":200,
"groupId":300,
"clobObjId":1257697772,
"typeCode":5,
..........
}
I need to take the new record's ID (1257697771) value returned in order to perform updates, get by ID, delete, etc. on this record in other threads.
After much reading, I've created a Regular Expression Extractor where:
Apply to: Main Sample Only
Field to Check: Body as Document
Reference Name: newRecord
Regular Expression: "id":(.+?)\,"displayName"
Template: $1$
Match No: 1
Default Value: NONE
At this point, I'm not sure if my Regular Expression is formatted correctly where (.+?) is valid.
Also, I'm confused if I can either just specify the new reference (newRecord) in another thread's HTTP request's Parameters or use a BeanShell Post-Processor, or a Response Assertion, etc....
There a lot of answers for the same function of "Passing". Not being a programmer, I've tried to follow the discussion "how to extract json response data in jmeter using regular expression extractor?", but I'm still not clear.
Any insight is appreciated. Thanks.
JMeter Variables are local to Thread Group, you need to convert your variable to JMeter Property.
Use:
__setProperty() function in the Thread Group where you define your newRecord variable like:
${__setProperty(newRecord,${newRecord},)}
__P() function to access property value like:
${__P(newRecord,)}
See Knit One Pearl Two: How to Use Variables in Different Thread Groups article for more detailed explanation.
Also be aware of the Function Helper Dialog as it looks like JMeter functions syntax was developed by aliens.
To pass a value between threads you need to use the jmeter property function.
In a jsr223 postprocessor using groovy the code to get the value is as follows:
def userProperty = props.get('propertyToGet')
vars.put('userProperty', String.valueOf(userProperty))
You would then access the variable in your thread using:
${userProperty}
Or you can use shorthand directly:
${__P('propertyToGet')}
Variables in jmeter are thread specific.
Thanks everyone. I was able to resolve it with your help!
In the first thread:
set the Reg Expression Extractor Regular Expression = "id":(.+?)\,"displayName"
added a Bean Assertion where Parameters = ${__setProperty(newRecord,${newRecord},)}
In the second thread:
appended the Path url with ${__P(newRecord,)}
Executing the first thread (POST) resulted an new record with a unique ID. (1257698108)
Executing the 2nd thread (GET) shows
GET http://server/.../.../.../.../1257698108
And returns the exact data generated in the first thread.
Thanks everyone for your help!

JMeter - xpath extractor not writing to user-defined variables outside thread group

I am having a problem with JMeter. I have a thread group with a web service request and an xpath exctractor. I set the reference name field in the xpath extractor to a user-defined variable that's defined outside the thread group. However, that user-defined variable is never set. I know because any subsequent web service request that references that user-defined variable fails.
Note that this is NOT a problem when I place the user-defined variables within the same thread-group as the web request. Then, the user-defined variable gets set.
How do I work around this bug? I need a way for one thread group to set a user-defined variable through the xpath extractor, so the user-defined variable can be used by another thread group.
Greetings,
This is actually a feature of Jmeter. (I know..I cringed just writing that). Variables are local to the thread group. The only way to share variable values between threadgroups is to use properties.
There are two functions you'll need to use:
${_setProperty} and
${_property}

Resources