How do I pass a variable from one Thread Group to another in JMeter
I was not able to do this with variables (since those are local to individual threads). However, I was able to solve this problem with properties!
Again, my first ThreadGroup does all of the set up, and I need some information from that work to be available to each of the threads in the second ThreadGroup. I have a BeanShell Assertion in the first ThreadGroup with the following:
${__setProperty(storeid, ${storeid})};
The ${storeid} was extracted with an XPath Extractor. The BeanShell Assertion does other stuff, like checking that storeid was returned from the previous call, etc.
Anyway, in the second ThreadGroup, I can use the value of the "storeid" property in Samplers with the following:
${__property(storeid)}
Works like a charm!
How to pass a set of values from one Jmeter Thread group to another
You can save different variables per thread using __threadNum function
${__setProperty(categoryID_${__threadNum}, ${categoryID})}
And then get it using same function:
${__property(categoryID_${__threadNum})}
Share Variables Within JMeter Thread Group
- You can "stick" each thread (virtual user) to its own ID (or set of IDs from the CSV), i.e. use separate files for each user and __CSVRead() function or single file and __groovy() function to read the values
- If you still want to continue with your approach take a look at Inter-Thread Communication Plugin which provides a FIFO queue
- Another way is using JMeter Properties if form of name-value pairs of ID=cookie_value, if there is no cookie value for the ID - write the value into the property, if there is - read the value from the property instead of requesting a new cookie
How to pass parameter (token) to another thread group , i need to use the parameter pass from another threadgroup as dynamic url
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
How to use a variable between two thread groups
You can't share a variable, you can convert variable to JMeter property using __setProperty
${__setProperty(propertyName, ${variableName})}
The setProperty function sets the value of a JMeter property.
And use in second thread group use __property
${__property(propertyName)}
You can convert it back to JMeter variable:
${__property(propertyName, newVariableName)}
${__property(user.dir,UDIR)} - return value of user.dir and save in UDIR
Related Topics
Java - Removing First Character of a String
How to Get Client Information Such as Os and Browser
How to Create a Custom Exception Type in Java
Kill -3 to Get Java Thread Dump
String.Format() to Format Double in Java
Java Method Invocation VS Using a Variable
Visual Studio Code, Java Extension, How to Add a Jar to Classpath
Calling Win32 API Method from Java
Java's Bigdecimal.Power(Bigdecimal Exponent): Is There a Java Library That Does It
How to Execute Multiple SQL Statements from Java
Adding 3Rd Party Jars to Web-Inf/Lib Automatically Using Eclipse/Tomcat
Java Simpledateformat Timezone Offset with Minute Separated by Colon
Play a Youtube Video Using Javafx
Printing Even and Odd Using Two Threads in Java
Java.Sql.Sqlexception: Incorrect String Value: '\Xf0\X9F\X91\Xbd\Xf0\X9F...'