Let us consider we have an excel/csv containing multiple columns, column1 contains the website and the other columns contain the parameters, how to perform http GET login and map parameters of each site and get the result sheet in jmeter. Can someone help in solving this issue....
Thanks...
you can map columns of the csv file with CSV_Data_Set_Config
by setting variables names to : url,user,pwd.
after that you can use them on another components like this '${user}'
do http request HTTP_Request
and save the result with Save_Responses_to_a_file or to see them View_Results_Tree
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 am facing an issue while reading the data from CSV file to pass the values to the request. I have a csv with 3 columns userid, password and type.When the data is being passed for the username field, its taking the values of 3 columns instead of just the username
Jmeter version: 5.0
CSV file value:
Can you please help me if i am doing it wrong.
Double check the "Delimiter" in your CSV file because if it's different from the default comma , you will need to change it accordingly:
In order to be 100% sure in the test data integrity I would recommend opening it with a text editor like Notepad instead of Excel as JMeter treats CSV files as plain text and this is you should be also doing when validating your test data.
You may find Debug Sampler useful for visualising JMeter Variables which are generated by CSV Data Set Config, Post-Processors and some pre-defined variables.
Let me see the variable you insert into the Login request. Everything is find with your config. Maybe it about your CSV file. Please sure format of CSV file when you open with Notepad not Microsoft Word like this
userid,password,type
test#test.com,Test#123,Vehicle
test#test.com,Test#123,Vehicle
test#test.com,Test#123,Vehicle
With Jmeter, how can we create users using CSV file because at CSV it is picking first userid and if re-running the script it will say user already exist.
Please help me to create users.
If you need to create a new user every time you run the test it doesn't make sense to use CSV files and CSV Data Set Config, I would recommend using following JMeter Functions instead:
__time() - returns current timestamp in different formats
__Random() - returns a random number in given range
__randomString() - returns a random string from given characters
You can also use any of above functions as prefix or postfix for username from the CSV file - this way you will get new unique logins each time you will run your test
Abdul, you can concatenate random number using __Random function in the request where you are passing the userid [picked from the csv file] for creating the user.
For example: Your .csv file contains userid as:
ravi
abdul
Now, in the http request pass the userid picked from the csv file and concatenate __Random function
Example: ${userid}${__Random(1,100000,str_ran)}
Additionally, you can also get the list of userids created in the test run by writing a simple code in Beanshell Postprocessor that can create a separate .txt file with all the userids.
Let me know if you need any further information.
You can get more information on JMeter elements from the knowledge base
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.
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