How to pass parameters in Jmeter for username and login.? - jmeter

I have just been assigned the tasks of doing some research and doing some JMeter tests for performance testing. As I have never used this tool before.!
I just added the IP or address of my project, in that screen there is two textbox for username and password lets say its id are User1 / Pass1. I'm having several authenticate credentials to check. so how can i parameter those from an external sheet.?

The most popular approach to provide external data to parametrize JMeter tests is Using CSV DATA SET CONFIG

You can also use User Parameter Pre-processor.
You can add variable with name value pair in this pre-processor.
For e.g. :
name : id value : abc
name : pwd value : xyz
you can then refer these variables in your samplers as ${id} & ${pwd}
Also you can increase the users count just by adding more users.
See below image for more details.

Related

Passing one api parameters value to another api

In JMeter I have two Api , one api generate filename and id then these parameters pass to another api here I used plugin path extractor and also use csv data set config to extract , save and pass parameters and its value to another api but problem is when multiple user it generate multiple filename and id but how to pass those file name and id to every httprequest to another api.
You don't need any CSV Data Set Config, it will be sufficient to
Add a suitable Post-Processor to extract the generated file name
The Post-Processor will store the generated name into a JMeter Variable
You should be able to use the variable in the "2nd API"
As per JMeter Documentation Variables are local to a thread so each thread (virtual user) you define in the Thread Group will have its own value.
Demo:
More information on JMeter Correlation concept: Advanced Load Testing Scenarios with JMeter: Part 1 - Correlations

How to deal with dynamic parameter name in JMeter

Login page is having dynamic password field name: every time user visits the login page field name looks like PASSWORD_673834937, and on next visit, it looks like PASSWORD_673857943.
I have created many scripts which were working as of today, but in latest build they bring in this change to the password field... before this it was always PASSWORD only. So all my scripts were failing. What is the workaround, so that all my scripts start working with dynamic field name?
OLD JMETER SCRIPT using name as "PASSWORD"
NEW changes to the password field
Under register.asp sampler, add RegEx Post-Processor
Specify the following parameters:
(i.e. the regular expression is <input TYPE="password" NAME="([^"]+)")
In HTTP Request, in the row where password is provided, specify variable created by RegEx Post-Processor in Field name, instead of static name. For example, since the variable I created above is called PasswordFieldName, the HTTP Sampler should look like this (omitting irrelevant parameters):
This is a matter of missing correlation, you would need this sooner or later given you continue playing with JMeter.
The idea of bypassing dynamic parameters is building your Test Plan as follows:
Request 1 (open login page)
Extract dynamic parameters and store them into JMeter Variables
Request 2 (perform login) providing credentials and all dynamic variables from the previous step
Add CSS/JQuery Extractor (be aware that it is not recommended to use regular expressions to work with HTML data) as a child of the register.asp page and configure it as follows:
Reference Name: anything meaningful, i.e. name
CSS/JQuery Expression: input[title=Password]
Attribute: name
Replace PASSWORD_673834937 with ${name} in the new script.

JMeter MultiUser and single user Auto Login Script

How to check Multiuser and single user Autologin Load test in my website..
I have studied the tutorial but I don't understand it. Below are the steps that I follow..
Test->Add->Theard Group ->Recording Controller
Test->Add->Config Element->HTTP Request Default
Test->Add->Config Element->HttpCookie Manager
Workbench->Add->NonTestElement->Http(s)Test Script Recorder
I set Httpdomain name->adda52.org, http sampler settings and add exclude patterns in Step 4 and then start. After that I set the browser setting proxy server and run login our site..
Everything is going fine.
Then I add view result and see that the result of each request is fine. Then I pass a dynamic session value by using the following steps:
under Recording controller->login page->add->Post Processer->Regular expression extractor add under reference
name salt (This is my session id)
Regular Expression name="salt" value="(.*?)" />
Match No 1
Default value = session Not found
and then set this session value is my after login page like this : ${salt} and run our script session value is showing on my post data.
My question is
Is my script is correct? if yes then
After login I cannot see on profile page in Response data in View Result trees they are showng blank page ?
How can I make my script to auto login on multiple users and single user?
How can I check load on my site and where
please provide me step and how to check.?
Follow these steps carefully:
List item
test plan->Add->Thread(user)->Thread group
thread group->Add->config element->HTTP Request Defaults
thread group->logic controller->recording controller
Workspace->Add->non-test element->http test script recorder
start your plan & record it.after successful creating of test plan do the following steps: add the csv data set config in your test plan
Thread group->add->config element->csv data set config
in csv data set config file give the parameter values like : in filename:-give your csv file path & in variable name pass the variable as:username,password
in your test plan check the login file in that file change the static values username as "${username}" & password "${password}"
pass the different values in csv file & before start the test plan change the number of thread you want run

Read a string from a file with a dynamic name in JMeter

My test plan contains a thread group that looks like that :
Only once controller : Login to application
CSV Data Set Config : Info used to login to application
Only once controller
HTTP Request : POST login information
Loop controller (10 times)
HTTP Request : POST add a "comment" to a "question"
My CSV dataset contains these fields :
username
password
group_id
A user have access to a question depending on it's group_id. I want to add 10 comments per thread to different questions.
My idea was to build a file like questions_by_group_${group_id}.txt containing some ids of questions that the ${group_id} would have access. Then I could do ${__StringToFile(questions_by_group_${group_id}.txt)} in the POST parameter value to add a comment. Using __StringToFile function should loop through lines of my file at every call. That way I can add many comments to many different questions.
The problem is that JMeter seems to open the file one time and share it for every thread (even thought I know that the ${group_id} changes for every thread.
I tried many things like
${__StringFromFile(questions_by_group_${group_id}.txt)}
${__StringFromFile(${__eval(questions_by_group_${group_id}.txt)})}
${__eval(${__StringFromFile(${__eval(questions_by_group_${group_id}.txt)})})}
but nothing works.
StringFromFile works this way by default, read:
__StringFromFile
You could organize your csv like this:
username, password, group_id , commentID1, commentID2....
Then put CSV Data Set Config before Once Only Controller.
Set Sharing Mode to All threads for example.
Finally just use variables instead of using __StringFromFile.
It's not the best solution as you have to build this file and repeat group_id ids.
Another option, if your number of groups is not very big, would be to do this in a setUp Thread Group:
read a CSV file containing:
groupID1, IDA1, IDA2,....
groupID2, IDB1, IDB2,....
...
set one property per group __setProperty or calling this inside a Beanshell Sampler:
JMeterUtils.setProperty(propertyName, propertyValue);
Then in your controller, use a Beanshell Sampler to get ids using:
JMeterUtils.getProperty(propertyName);
I must say I hate all these solutions :-)

JMeter : how to use the timestamp of the parent

I'm testing a group of urls for performance tests. We have an SLA that states that a certain group of URLS must have an average of 80% success within a certain timerange.
The logic of the sla is done in a separate application. The data is fed from JMeter output into a database.
I need a way to identify the 5 tests of these urls, so that the application knows they belong to the same test. I use a Transaction Controller to group all the URL tests, but I still don't see how I can put an identifier in the generated output file (done by View Results Tree Listener). If I could reuse the timestamp of the parent, i.e. the Transaction Controller for the individual HTTP Requests, that would make my day. I tried adding User Defined Variables under the Transaction Controller, but I don't see how I can output the value of my variable into the output file.
Is anything similar possible?
Best regards,
Wim
Store your value in jmeter context using a Beanshell sampler then in jeter.properties uncomment sample_variables ans add the name under which you stored your value:
Optional list of JMeter variable names whose values are to be saved in the result data files.
Use commas to separate the names. For example:
sample_variables=SESSION_ID,REFERENCE
Regards
Philippe M.

Resources