How to read synchronizing timer parameters value from csv file.
CSV file consists of two columns: Value and Count
I want to read 'Count' field value to parameterize 'Number of simulated users to group by field' .
I have tried :
1)${__BeanShell(1*${Count})}
2)${Count}
Add csv config file in your as child of your http request and add the following
and then add the following in sync timer
And your csv should look something like this
Related
I have a JMeter test scenario as follows: several hundred users have to login to a platform and send a POST request with several hundred of profiles to generate a report. For the data, I use two csv files.
One csv file contains the data of the users with which JMeter will login and send a POST request to generate a report. It contains the following fields:
userid, companyid, password
once logged in, each of these users has to choose profiles from another csv file, to generate reports about those profiles. The other csv file has these fields:
profileid, companyid
Each user can only generate profiles of the profiles that have the same companyid.
The profiles have to be placed inside an array, which in turn is inside an object, in a JSON request. IMPORTANT: all the profiles have to be placed inside the array in a single iteration. That means that if there are 1000 profiles, they have to be set on the array at the same time.
I haven't been able to:
Figure out how to ensure that for each user, the specific profiles available to that user get set in the array.
Figure out how to actually insert the values in the array, all in a single iteration .
Could someone offer advice on how to achieve this?
Disclaimer: I don't know Java and I have just begun using JMeter a few days ago.
It's hard to provide a comprehensive answer without seeing your CSV files structure so I can provide only a generic piece of advice:
If you're looking at CSV Data Set Config be aware that it reads the next line on each iteration, if you need to read multiple lines within the bounds of a single iteration you need to use __CSVRead() function or consider using JSR223 Test Elements for scripting
Solution 1
You can use a CSV Data Set Config element to read the data, userid, companyid, password from the first CSV file.
Add a CSV Data Set Config element to read the user credentials.
It will read one row for each thread and each iteration.
Now you have the companyid available for the entire iteration. You need to filter the data with the companyid from the second CSV file. This can be done with Groovy (you can use Java too).
Add a JSR223 Sampler to retrieve the profileid from the second CSV file. Following code demonstrates reading the CSV file into list of files and then filter the lines with companyid
log.info("Processing profile")
def lines = new File('company_profiles.csv').readLines()
def filteredLine=lines.find { it.contains(args[0])}
def lstRecord = filteredLines.get(currentRecord).split(",")
vars.put("profileid","${lstRecord[0]}")
SampleResult.setIgnore()
NOTE : companyid is passed to the script as an argument. Please see the highlighted areas in the following.
The profileid is set as a variable in the script vars.put("profileid","${lstRecord[0]}"). You can use the profileid within the iteration of the current thread with ${profileid}
I need to read two values from two different rows in a csv and pass those values as a part of the body of a POST request.
Through CSV data set config I'm able to read only one value at a time. Is there any way I can read two values in the same request?
Example:
sourceSystemGuid,sourceSystemName
sourceSystem_733,sourceSystem733 sourceSystem_590,sourceSystem590
sourceSystem_959,sourceSystem959
I need to read two values for sourceSystemGuid in one request.
Without custom scripting it’s not possible.
But you can put 4 columns per line and that will do what you want.
In my script i have a loop controller before a bunch of requests,and i have parameterized the request data for eg. in my case it is the row number I parameterized. I added a CSV file before the thread group too.Issue is it is only taking the first row of variables in excel file.I understand the sharing options are All Threads,Current Thread,Current Thread Group so it will take next row values in the next iteration.How to make the Csv file work in a loop controller to pass next row values?
Do u mean the iteration due to loop controller or the loop count in thread group?
enter image description here
CSV Data Set Config should be under Loop Controller (which is under Thread Group).
That how each line will be taken for each loop iteration.
-Thread Group
...
-Loop Controller
- CSV Data Set Config
I know using of data driven in jMeter by passing the values in parameters, but my concern is how to the data driven testing when the values are sending in request of a body. Any help will be appreciated
You can use CSV Data Set Config, Add > Config Element > CSV Data Set Config
In the CSV file you can set the value for the parameters.
example csv file
Provide csv file path in CSV Data Set Config
Imported CSV file will be the data to perform data driven testing for login page, where first row of the csv file is variable name and rest is test data.
Set the number of thread user under Thread Group same as number of rows present in the csv file.
Have you tried fill body like this?
MyVariable is user defined variable
CSV data config always reads from first row. I want to add column headers in the CSV file. Hence I want the CSV config to start reading from second row.
Below is the setting in Thread Group.
No.of threads = 1
Loop Count= 10 (depends on no.of rows in CSV file)
What version of JMeter are you using? It seems like leaving the Variable Names field empty will do the trick. More info here:
Versions of JMeter after 2.3.4 support CSV files which have a header
line defining the column names. To enable this, leave the "Variable
Names" field empty. The correct delimiter must be provided.
Leave the variable names empty like on an attached snapshot.
In csv file add header. Header values will act as variable names which could be used as parameters in requests.
~sample facility.csv file
facility1,name
GG1LMD,test1
Request
There is a field called "Ignore first line (only used if Variable Names is not empty)", set this to true.