I have two thread groups
Creation of customer
Creation of account
From first thread group I'm capturing a variable called customerId.
How can I use that variable in second thread group?
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
When we define a filter in Workshop, the output object set is used to apply users' filter options to another widget.
But it's also mentioned in the documentation that setting this variable is a mean to provide et default value: how does it actually work? I mean, how to shall I do to set this variable (I do not even know how to put a static value) with, for instance, the output of another widget (let's say a multi select table)?
The output of a Filter List widget in Workshop is a filter-type variable. To get an Object Set that reflects this filter, you then create a separate Object Set-type variable and use the configuration option there to choose one or more filter-type variables to apply.
To set the defaults of the filter so that they show up as selections in the Filter List, you can edit the default configuration for the for the output filter variable. First you have to choose the object type to which the filter corresponds and then you'll have access to the various properties of that object type. You can set a static default or you can choose a "typed" Variable (string, number, date, timestamp) and make that the default.
You can then get creative about where those variables are sourced from to wire together dynamic default selections for the Filter List values.
I am setting a property value through JSR223 pre-procesor and want to use this property for source directory in Directory Listing Data Source but, not been succesful. Here's how i am trying to do it.Have i missed something?
setpropertyvalue
usepropertyindirectorylisting
The reason I want to do this is because I want to use files from different folder in each thread. I have named folders as ABC1, ABC2, ABC3 etc...and that is why i want to use thread number function for ABC${threadNum}. But, i am not able to achieve it.
It should work fine given you set the property before the directory listing config is initialized.
Take a look at JMeter Test Elements Execution Order
0. Configuration elements
1. Pre-Processors
2. Timers
3. Sampler
4. Post-Processors (unless SampleResult is null)
5. Assertions (unless SampleResult is null)
6. Listeners (unless SampleResult is null)
So as you can see Configuration Elements are being executed before anything else so you either need to
define your property in another configuration element which will be executed before the Directory Listing Config such as User Defined Variables
or move your code to setUp Thread Group
or provide the property value via -J command-line argument
I have a BeanShell PostProcessor under the setUp Thread Group.
It generates an ArrayList that I want to pass as a system property to the test Thread Groups in the Test Plan.
That array contains the number of threads in the test groups.
What is the syntax? How should I refer an element of that array in the Tread Group "Number of Threads (users)"?
This is what I have in the setUp Thread Group
ArrayList users = new ArrayList();
${__setProperty(users, ${users})};
This is what I put in the Number of Threads
${__P(users).get(0)}
It does not work.
Thanks
If you really need the "ArrayList" you can go it using bsh.shared namespace
In setUp Thread Group put the ArrayList into the "bsh.shared" namespace like:
ArrayList users = new ArrayList();
users.add(5);
bsh.shared.users=users;
In normal Thread Group you can read the value via __BeanShell function as:
${__BeanShell(bsh.shared.users.get(0),)}
However I feel that your test is badly designed and you could get rid of scripting or at least of using arrays.
My first thread group parses a file and stores all the lines in a List. The second thread group should retrieve objects from the List one by one and send HTTPS request. Now the problem, how to make the list of objects (not just a property value) between thread groups Appreciate any help.
You can use Beanshell Test Elements and bsh.shared namespace to share variables across thread groups
In first thread group after parsing:
bsh.shared.myList = myList;
In second (or whatever thread group)
List myList = bsh.shared.myList;
See How to use BeanShell: JMeter's favorite built-in component for more scripting options.
If you use different scripting language (not Beanshell) - it is still possible to use props pre-defined variable which stands for JMeterProperties instance. JMeterProperties is basically an instance of java.util.Properties so you can store any object in there like:
In first thread group:
List myList = new ArrayList();
//do what you need with the list
props.put("myList", myList);
In second thread group:
List myList = props.get("myList");
// do what you need with the list
I'm using the environment variable $PMTargetName#numAffectedRow, but the TargetName is a parameter(parfile)
I'm trying to do this way:
$PM$$SOURCE_TABLE#NumAffectedRows
Is not working :/
What you need to use here is the name of the Target Transformation, not the table name. So assuming you've got a Target Transformation named MyTargetTable and you use the Target Table Name property to set the actual table name to e.g. Customers, then:
$PMMyTargetTable#TableName should give you Customers
and $PMMyTargetTable#NumAffectedRows should get you what you're looking for
The variables to be used in pre/post session commands need to be passed to the session from parameter file. e.g. $PMTargetName should be used in your session e.g. as Target Table Name. If you are doing this, then this will work - ${PMTargetName}#numAffectedRow. Adding parentheses will ensure your variable is expanded before #numAffectedRow is appended to it.
If you are not using $PMTargetName anywhere in your session then IS will not expand it. You should declare it as your workflow variable. And since you have already defined it in parameter file...rest should work.