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

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.

Related

how to pass created token in 2nd thread group

How To pass token in 2nd thread group.
I have tried adding json extractor in 1st thread group and then added beanshell preprocessor in 2nd thread group
I am getting invalid token
Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy for scripting.
You need to convert the JMeter Variable holding your token into a JMeter Property, for this add a JSR223 PostProcessor after the JSON Extractor and put the following code to "Script" area:
props.put('token', vars.get('variable-holding-your-token'))
In 2nd Thread Group you can use __P() function for accessing the token like:
${__P(token,)}
More information: Using JMeter Variables With Multiple Thread Groups

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

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

Passing one api parameters value to another api

In JMeter I have two Api , one api generate filename and id then these parameters pass to another api here I used plugin path extractor and also use csv data set config to extract , save and pass parameters and its value to another api but problem is when multiple user it generate multiple filename and id but how to pass those file name and id to every httprequest to another api.
You don't need any CSV Data Set Config, it will be sufficient to
Add a suitable Post-Processor to extract the generated file name
The Post-Processor will store the generated name into a JMeter Variable
You should be able to use the variable in the "2nd API"
As per JMeter Documentation Variables are local to a thread so each thread (virtual user) you define in the Thread Group will have its own value.
Demo:
More information on JMeter Correlation concept: Advanced Load Testing Scenarios with JMeter: Part 1 - Correlations

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

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!

Resources