How to pass unique data from csv file into jmeter - jmeter

I am using the jmeter for load testing a web application.I am using csv Data Set Config to pass email to test login scenario.While i am running with 100 concurrent users,it is picking same email from csv file.How can i make sure that it will use one email only once.

I was facing the same issue during concurrency testing using CSV data config. By enabling Sharing Mode=All Threads in CSV data config solved my problem and i was able to send unique data per request

Use Random String Function for generation of different email ids,
RandomString function returns a random String of length using characters in chars to use.
It has three parameters,
1. Length of the desired random string
2. Source characters
3. If you need to store generated string into a JMeter variable you can provide variable name as 3rd argument.
${__RandomString(6,a12zeczclk, MYVAR)}
Example as,
${__RandomString(10,abcdefghijklmnopqrstuvwxyz,)}#MyMail.com

Related

How to save value from multiple requests to one file in Jmeter

I have one GET request which returns a token. I need to run this request 50 times and each returned token is appended to a single file or array which I can randomly choose and use tokens for other requests. Is it possible in Jmeter
Add a Post-Processor to extract the token and save it into a JMeter Variable
Declare the variable as a Sample Variable
Save the extracted value into a CSV file using Flexible File Writer
Use Random CSV Data Set Config to read the random token from the CSV file created in the previous step

Jmeter can get parameters?

My question is - if I run a test via Jmeter, for example , if it's a site which enables you to book a flight, and you choose your source and destination when you record it.
Is it possible to pass different values to the destination field? I mean, maybe a txt file with some destinations and pass it to the Jmeter test and then, you will have some tests which each of them is running with a different destination?
If yes, how can I do it?
It's not necessary that it will be a txt file. Just a way to pass different values to one parameter.
Important: I'm using blazemeter plugin for chrome.
Thanks a lot,
appreciated.
You can use CSV Data Set Config. It is very easy to use for parameterizing variables in the test plan.
Check this article on blazemeter to understand the CSV Data Set Config quickly.
Depending on what you're trying to achieve you can go for:
HTML Link Parser. See Poll Example which shows how you can use it for selecting random values from inputs
You can extract all the possible values from the previous response using a Post-Processor, most probably CSS Selector Extractor and configure each thread to use its own (or random) value from the input
And last, but not the least, you can use an external data source like .txt or .csv file and utilize __StringFromFile() function or CSV Data Set Config so each thread (virtual user) would read the next value from file instead of using recorded hard-coded values.

In JMeter how do I set multiple dynamic variables in User Parameters or CSV Data Set Config

Very new to JMeter (and a long time Stack Overflow listener but first time caller so take it easy on me) so any help would be appreciated.
I am trying to set up a JMeter test that uses multiple dynamically generated access tokens to run across scenarios. I currently have a set of data using the CSV Data Set Config containing login credentials of a user's email and password for example:
email1#email.com,password1
email2#email.com,password2
Next I send a HTTP POST request to the Login service which generates an accessToken. Then, I am using the JSON Extractor to grab the generated accessToken. After that I am using the BeanShell Assertion to store the accessToken property/variable.
My issue seems to lie here in this last step since it will only store the last generated variable instead of each of the generated accessTokens. I want to be able to store/overwrite the grabbed accessToken for each email password combination. I would like it to modify/populate the CSV file like this:
email1#email.com,password1,accessToken1
email2#email.com,password2,accessToken2
I have also tried using the Pre Processor > User Parameters
Screen shot of User Parameters
I would like to have the "userBearerToken" variable update/overwrite along with the tests, but I cannot find a way to do so or if this can even currently be done.
I'm finding it difficult to word what I am trying to ask, but basically I want to store multiple dynamically generated variables (accessTokens that change and time out) and use them in other tests. I don't care which component can handle this (either the CSV or User Parameter), but I need to be able to store these variables with their corresponding email password credentials.
If you want to store the accessToken value into a JMeter property for using in other Thread Group(s) be aware that properties are global for the whole JVM and remain until JMeter is restarted so if you define a single accessToken property - each JMeter Thread (or iteration) will overwrite the value.
The solution is to use current thread (or iteration) number as prefix or postfix, this can be done using either __${__threadNum} function or relevant JMeter Variable depending on how iteration is defined or both.
Example setup:
In first thread group: ${__setProperty(access_token_${__threadNum},bar,)}
In second thread group: ${__P(access_token_${__threadNum},)}
Demo:
If you want to save the values into a file writing into the current one is not the best idea as you can (and most probably will) get malformed file due to a form of a race condition. So I would recommend using Sample Variables property instead.
If you add the next line to user.properties file:
sample_variables=email,password,accessToken
JMeter will store the variables named ${email}, ${password}, and ${accessToken} along with their values in the .jtl results file which is basically CSV file which can be re-used anywhere else.
However if you have a requirement to store only the credentials and the token you can go for the Flexible File Writer plugin and configure it to save the aforementioned variables values into a separate file, the relevant configuration would be as simple as:
variable#0,variable#1,variable#2
You can install Flexible File Writer plugin using JMeter Plugins Manager

How to hit parameterized url in Apache Jmeter?

This is my test URL " http://appr.seconddemo.org/hitssurveys/survey?uid=113&offerid=311&subid=subvalues&offr_id={Email} "
I want to hit the url 1500 times per second , and want to change the "{Email}" with real value in each iteration.
How it's possible please give me a step by step guide.
Considering that you need to pass the emails from the external file, the most efficient way that we are using in software testing companies is to pass the variable from .csv or .txt files using 'CSV Data Set Config' element of the JMeter.
Please find the steps that you need to follow:
Add a 'CSV Data Set Config' element from 'Config Element' by right-clicking the thread group
Set Filename field with complete path to your .csv or .txt file that contains your emails
Set Variable field as 'Email' [This variable name should be same as you set in your url request]
Ignore first line to False
Set other fields as per your requirement
Now add HTTP Sampler in your Thread Group and set the Protocol, Server Name, Method & Path as instructed in the screenshot:
Create .csv or .txt file and add all emails separated by new line:
Hope this answer is useful.
You can use the CSV Data Set Config. Put all your email credentials in the CSV file and make sure you have put this CSV file in your JMeter /bin directory.
Add a CSV dataset config in your test plan. Your CSV dataset config should be like:
Now in your thread group, define the number of threads you want to execute and then in your sampler put the path as follows:
http://appr.seconddemo.org/hitssurveys/survey?uid=113&offerid=311&subid=subvalues&offr_id=${Email}
Depending on where do your emails live there are following options:
If they are in a text file, each email on a new line you can use __StringFromFile() function like:
If they are in a database you can use JDBC PreProcessor to fetch the data from the database table column and put your request under ForEach Controller
If you need to provide just some random characters you can use __RandomString() function.
More information: JMeter Parameterization - The Complete Guide

Printing variable value from CSV data file to JMeter console

I am using JMeter to performance test an address validation service that finds valid addresses for an insurance quoting application. I am testing this from the back end using soap requests and I have a csv data config file with a large number of search strings.
In order to get a true idea of the performance of this service, I need to test with a large number of addresses i.e. over 30000 so that the server caching doesn't affect my performance results. I have a list of addresses in a csv spreadsheet but some of them cause failures for whatever reason (e.g. the address no longer exists, I have verified this when just submitting one request with the address in question). I want to remove all addresses that fail from my csv file.
So I wanted to use JMeter to print the search address to the console if the request with this particular search address fails. I tried to use an IF controller with this as the condition "${JMeterThread.last_sample_ok}" == "false" and the following in the name section so that it prints the address to the JMeter console. The parameter searchAddress comes from my CSV input file. When I try and run this it just prints ${searchAddress} to the console. So the if statement works but it doesn't recognise searchAddress as a variable.
If I can get this to work I would copy all the search strings to excel and use a formula to remove them from my list of addresses to be used by my JMeter thread.
Sorry for the lengthy question, but hope I have explained my issue clearly.
An alternative is to use a BeanShell PostProcessor as child of which ever component receives the error; In the Beanshell, something like:
String searchAddr = vars.get("searchAddress");
//Output to Console
System.out.println("Failed Address = " + searchAddr);
//Output to Log file etc.
log.info("Failed Address = " + searchAddr);

Resources