Issue with excluding a data in Jmeter Testing With CSV - jmeter

I have an api Request such as this
"partnerServiceId":"${partnerServiceId}",
"customerNo":"${customerNo}",
"virtualAccountNo":"${virtualAccountNo}",
"virtualAccountName":"${virtualAccountName}",
"sourceAccountNo":"${sourceAccountNo}",
"partnerReferenceNumber":"${partnerReferenceNumber}",
"paidAmount":"${paidAmount}",
"trxDateTime":"${trxDateTime}"
The First column partnerServiceId is not needed for this case. So here is the sample csv I made, for one row. I used ",,".
application/json,16786 f65a899b974397a0b7692cfde37ee0f953eb972b,,1282513558,112081000000000,Latifah Hanum,1901000000000,20211105018,10002.00,05/11/2021 08:44
Here is the variable setting I'm using in CSV Data Config
Content-Type,Authorization,partnerServiceId,customerNo,virtualAccountNo,virtualAccountName,sourceAccountNo,sourceAccountNo,partnerReferenceNumber,paidAmount,trxDateTime
The Result came out like
Content-Type: application/json
Authorization: 16786 f65a899b974397a0b7692cfde37ee0f953eb972b
and for the request body
POST data: --RY0QSC1feIvTe02NIdE1n4T8bJi3bK3yiR---
Seems like only the headers came out right, what am I missing ?

By default (with "Sharing mode" = All Threads) CSV Data Set Config reads next line from the .CSV file on each iteration by each thread (virtual user)
So if your CSV file really looks like:
application/json,16786
f65a899b974397a0b7692cfde37ee0f953eb972b,,1282513558,112081000000000,Latifah
Hanum,1901000000000,20211105018,10002.00,05/11/2021 08:44
you won't be able to use all the data in one iteration, either move everything into one like like:
application/json,16786,f65a899b974397a0b7692cfde37ee0f953eb972b,,1282513558,112081000000000,Latifah Hanum,1901000000000,20211105018,10002.00,05/11/2021 08:44
or consider switching to __CSVRead() function where you have more or less full freedom regarding which column to read and when to proceed to the next line

Related

Jmeter - Need to check empty tags in SOAP request

I have a SOAP request. I need to use jmeter to test multiple requests for same method, each time passing one missing element.
How can I achieve this ?
I tried writing the tags into csv using CSV data config , but I am unable to enter empty values in the csv, each time for a different tag in each csv row.
Any help would be appreciated. Thank you.
The CSV Data Set Config will read the value from next line only on the next iteration of the thread (virtual user), you cannot read more than one line within the bounds of a single iteration. You might want to take a look at __CSVRead() function where it's you who decides when to proceed to the next line.
If the __CSVRead() function isn't applicable for your use case be aware that you can build a request body, i.e. XML from CSV file using JSR223 PreProcessor and Groovy language.
See Creating XML chapter of Groovy documentation for more details.

How to read random data for each request in JMeter

I have 4 input parameters which I need to pass in my http request sampler. Everything is OK but the problem is how to first data i have to pass from the previous thread http response and rest 3 from the csv file. Please help.
It seems that you want to update a specific value of the CSV during execution. It would be wise to say that this can be achieved using if controller and User Parameters element. You can go through the below screenshots to resolve this problem.
CSV Data set config for reading csv values
CSV File
Here, I have added text "REPLACE_WITH_RESPONSE" so that we can match it in IF controller.
IF CONTROLLER
This will check if you want to replace this value or not.
Users Parameters
This element would be used to update the csv value with previous request response. In the below example, Date is the CSV value which is replaced with previous Response.
Hope the above solution will help you in resolving this problem.

Passing whole body as a variable to a POST request

I'm trying to create a simple stress test using JMeter. I have mostly GET requests and a couple POST requests. My main goal is to make this test as reusable as possible. I want to implement it in a way that the user would have to provide a CSV file with the following headers:
method;path;postBody
The values would look something like:
GET;/path/to/resource;''
POST;/path/to/resource;'{"key":"value","key":"value","key":"value"}'
Now POST (PUT, PATCH etc ..) bodies differ from one request to another. Providing ${postBody} to Body Data tab does not work "${postBody}" as well.
Is there a way to achieve this? Command line solutions are more than welcome as well.
EDIT: To clarify, I'm using the UI interface. When I input ${postBody} in the Body Data tab the UI complains. When switching from the Body Data tab to another one I get the following prompt:
Remove "'" around the request and it should work.
Regarding the warning you get, it is not an error, it is just that in JMeter those 2 tabs are exclusive:
Parameters tabs is for input of parameters in the form as name=value
Body data is for your kind of requirement
So can you test my hypothesis which is to remove the quote around the request in CSV file ?
If it still fails, please show the logs.
You can remain in Body Data tab,
Add after pathPost your optional query parameters for GET request:
${pathPost}?${getPramaters}
Don't worry about the ? it's just seperate path from parameters
Also consider changing variable name to path, more suitable because it can be POST.
In JSON , seperate between values while in CSV default is also ,
I suggest you can your CSV delimiter, In CSV Data Set Config Choose different Delimiter as ; and add your data in CSV accordingly (remove extra ' characters):
POST;/path/to/resource;{"key":"value","key":"value","key":"value"}
Notice: Allow quoted data keep default value False

I Want to add different values using csv config in my following code

In my below code i have to use multiple values in userEmail, userName, userMobile.
How can I do ti using csv config?
{"userDevicedId":"d0lfwViLwLQ:APA91bH4VSXS7VlthXhGQ4DPfb3otSUvwMnpmcK-mKyh7WN46xtDXWSYIOLB6Uw-nYr3zSBZOoiicpNuURQ2nR-a9vtwwSI8sehG-FbgYi4AaCdgurLG5C3Le4sYE0Lmp-piz_STLYnB","userEmail":"Tok#gmail.com","userMobileNo":"8989898995","userName":"Tik","userPasskey":"xmrVhb2MpmuzgLN941tGiLtdJnY3yvgMxlhXATEUa7SvsxclTiMLdJgPs7YTbNHF","userPassword":"Test123$$"}
Given your CSV file looks like:
someone#example.com,someone,1234567890
someoneelse#example.com,someoneelse,2345678901
etc.
Configure CSV Data Set config as follows:
Filename: full path to the CSV file
Variable Names: userEmail,userName,userMobile
Other config values - according to your scenario, see Using CSV DATA SET CONFIG guide for detailed explanation
Refer extracted values like ${userEmail}, ${userName}, etc. where required, i.e. if you want to send parametrised JSON it should look like:
{
"userDevicedId": "d0lfwViLwLQ:APA91bH4VSXS7VlthXhGQ4DPfb3otSUvwMnpmcK-mKyh7WN46xtDXWSYIOLB6Uw-nYr3zSBZOoiicpNuURQ2nR-a9vtwwSI8sehG-FbgYi4AaCdgurLG5C3Le4sYE0Lmp-piz_STLYnB",
"userEmail": "${userEmail}",
"userMobileNo": "${userMobile}",
"userName": "${userName}",
"userPasskey": "xmrVhb2MpmuzgLN941tGiLtdJnY3yvgMxlhXATEUa7SvsxclTiMLdJgPs7YTbNHF",
"userPassword": "Test123$$"
}
If you're using HTTP Request sampler, switch it to "Body Data" mode:
Remember that CSV Data Set config reads next line each iteration so make sure you provide enough loops on Thread Group level or via Loop Controller

Automatically generate HTTP request URLs in JMeter

I have an API call URL similar to this:
http://domain.com/rest/getValues?apiKey=sdfsdf&customerId=2200&timestampBegin=2013-08-15%2018:00:00%20CEST&timestampEnd=2013-08-19%2018:00:00%20CEST
I would like to dynamically change the time stamps, as well as the customerId, picked from a given set of timestamps and customerIds. Is this possible to do in Jmeter (preferably through GUI)?
Assuming that you are have inputs coming from external CSV file, you can use CSV data set config as explained here.
Your test plan will look something like
Thread groups
CSV Data Set config (define the file path and the variable names. You will be able to read these variables in request.
HTTP Sampler
http://domain.com/rest/getValues?apiKey=sdfsdf&customerId=${custid}&timestampBegin=${begin}&timestampEnd=${end}

Resources