Assign a CSV file for the Global User Defined Variables - jmeter

How can I assign a CSV file for the Global User Defined Variables. The CSV file will hold multiple request body data for Concurrent hits. Please find the User Defined Variables screen shot attached for reference.

You cannot, User Defined Variables is basically a collection of Arguments, so you cannot set anything but Name, Value and Description in form of Strings.
You can use __fileToString() function like:
but you won't be able to access different columns this way.
Be aware that CSV Data Set Config has "Sharing mode", you can control the scope and behaviour by amending the value.

Related

how to pass the dynamic filename in csv data set config in jmeter while the dynamic names are generated to save data of previous request?

I have one http request whose response comes in nested json and using groovy i am saving that data in different csv file on the basis of conditions.
the name of csv file is generated dynamically and saved in a variable
using vars.put() function
vars.put("_cFileName",cFileName.toString());
when try to use this variable in csv data set config
enter image description here
getting error message
2022-01-19 16:58:39,370 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: File ${_cFileName} must exist and be readable
it is not converting the name to actual file name
But in case if file name is not dynaamic and the variable is defined under user defined variable in test plan it will able to convert to actual file name?
is there any way we can use the dynamic name created in an previos request post processor?
You cannot, as per JMeter Test Elements Execution Order Configuration Elements are executed before everything else, CSV Data Set Config is a Configuration Element hence it's being initialized before any JMeter Variables are being set.
The solution would be moving to __CSVRead() function, JMeter Functions are evaluated at the time they're being called so it's possible to provide dynamic file name there, see How to Pick Different CSV Files at JMeter Runtime guide for more details if needed.

JMeter - How to pass data from the CSV Data Set Config to the ForEach Controller

My .csv file contains only one column called domain
I have very simple script:
Thread Group
CSV Data Set Config
Debug Sampler - ${domain}
ForEach Controller (in has input variable domain and output variable out)
Debug Sampler - ${out}
It executes the first Debug Sampler but not the second one.
I assume that ForEach does not get the domain variable from the CSV Data Set Config.
Please help.
you are using the For Each Controller in the wrong manner. basically, it expects the input as a list of values, which can be accessed using domain_1, domain_2 etc where domain is the value defined in the Input variable prefix field. This controller is primarily used with the combination of Reg Ex Extractor, which gives similar out (list of values) and accessing mechanism of them (using domain_1).
In your case, domain_1 & domain_2 are not defined, samplers inside won't be executed.
So, you must create/provide the input in the format For Each Controller expects Or use other controllers like While Controller etc.
Note: In order to provide the list of values as For Each Controller expects from CSV file, you can define more columns as follows:
domain_1,domain_2,...domain_n
google,yahoo,...bing
so, you can define Input variable prefix as domain, and make domain_1 & domain_2 variables available to the For Each Controller (As defined in the column fields).

How to make header manager as dynamic in Jmeter

In my case my header manager value needs to be changed according to the user logged in how to achieve this.
If you have a list of users and corresponding header values in a CSV file - you can use CSV Data Set Config to read the values from file into JMeter Variables and use the variables in the HTTP Header Manager. Header names and values don't have to be dynamic, you can put a variable or a function reference there.
Also be aware of Scoping Rules when designing your Test Plan

How to do parameterization for file name text of csv data set config in jmeter

I am passing the value for file name text filed in csv data set config as ${filename}, this variable contains entire path and fetching it form one more csv data set config which is present immediate to the thread group and the variable which I am passing to csv data set config that is inside the if controller here I couldn't able to pass that value to file name text filed, getting problem.
CSV Data Set Config cannot use JMeter Variable as the "Filename". However it is possible to use __property function there.
So your test plan should look as follows:
Read some value into a JMeter Variable i.e. foo via 1st CSV Data Set Config
Convert foo variable into foo property via __setProperty function
Use ${__property(foo,,)} as a "Filename" in 2nd CSV Data Set Config.
For more information on different JMeter's functions see How to Use JMeter Functions post series

Using parameters as user Defined Variables?

We run our tests in non gui mode and pass in various parameters like Server, port, threads etc. We'd also like to run our test in GUI mode, and be able to change these parameters in the GUI.
What I wanted to do, was use 2x User Defined variable objects, and have one with static data we can edit, and another with parameters. That way the actual test plan doesn't change, but we can set variables as parameters, and just disable the static data one. Or disable the parameterized one when we want to run with static data.
But this doesn't seem to work - no errors nothing.
I do something similar, but I used a UDF for this.
What I did was set up my variables and use default values.
VARNAME VALUE
otl_PROTOCOL ${__P(otl_protocol,https)}
otl_PORT ${__P(otl_port,443)}
otl_THREADS ${__P(otl_threads,1)}
otl_REPS ${__P(otl_reps,1)}
otl_RAMP ${__P(otl_ramp,0)}
I did one for server name as well. This way, I can use the defaults here or I can pass in parameters in either the command line args or in my user.properties. This works very well for me.
How are you passing in values from non-GUI mode? via CSV, using properties, User-Parameters, etc.?
If CSV, this is an easy fix. Simply create a User Defined Variables (UDV) object at the Test Plan Level and "hard code" all your parameters (Server, port, etc.). Keep your CSV config. If you run in GUI mode, disable the CSV and enable the UDV. When you save the file, keep the CSV enabled and the UDV disabled - that way when you run from non-GUI it'll read the CSV file.
If using properties, I would do the following: Create a UDV with all your parameters (Server, etc.). Before entering values, copy the component so you have TWO identical UDVs. In UDV 1, enter the property value from the command line. In UDV 2, enter the "hard coded" values. Throughout your script, replace any references to the properties with variable references. It would look something like this:
UD1: UD2:
Name Value Name Value
SERVER ${__P(Server)} SERVER devdomain.com
PORT ${__P(Port)} PORT 4111
Some HTTP Request
Domain: ${SERVER}
If using user-parameters, it would be the same concept as above.
Actually i am using a function named as regular expression for getting value.
here i have to use variable under variable because there is lots of value with same boundary, so i have selected one paragraph as ${ABC} and fetching value from this paragraph ${XYLEM}. both the variable created as regular expression.tried with ${__V(ABC${XYLEM})};
${__setProperty{Search_Investment_Banking,$Investment_Banking}};

Resources