JMeter: How to make the referer field dynamic based on the situation - jmeter

Apart from the Home page Suppose there are 2 pages i.e page A ,Page B , first step user have to login, then if that user have the permission to view page Page A ,Page B then he can go to those page else on clicking those page name from the top navigational bar user will remain in the home page.
1 login
2 Home [If Login Successful]
|
Check if have permission to view --------- Logout
|Yes
2 Page A
|
Check if have permission to view Page B --------- Logout
|Yes
3 Page B
|
4 logout
Suppose there are 3 users ,i.e user 1 , user 2 and user 3. Now User 1 have the permission to view both page A , page B but user 2 have the permission to view only page A and user 3 do not have the permission to view any of this two pages.
i have used assertion under the page A sampler , page B sampler to check weather correct threads are accessing this pages or not that is system is allowing only the authorized person or not.
in the thread group i have opted if error occur then " stop thread " , thats why if any thread fail to assert then it is not getting counted in the future , thats why in the logout sampler only 1 thread is showing, and that thread is for user 1 because this user have the permission to view both page A ,B . and user 2 and 3 are not considered as they have fail assertion in the previous stages. so is there any way out that in the logout page i can send all those thread which have cleared the login section successfully irrespective of there view page permission.
so at the time of logout in the logout page for user 1 in the referrer field it will show the link of page b but for user 2 at the logout page referrer field value will show the link of Page A. and for user 3 it will be home page.
so can any one please tell me how the referrer field value can be change dynamically based on user permission in the logout page .

This is a possible scenario, as I don't know how you are checking the permissions of the logged users.
HTTP Request - Login
Regular Expression Tester - capture an expected value to validate login
If Controller - If Login OK
HTTP Request - Home
Regular Expression Tester - Referrer to Home (Headers option maybe)
HTTP Request - Page A Permission Verifier
Regular Expression Tester - extract permission validation value
If Controller - If user has permission to Page A
HTTP Request - Page A
Regular Expression Tester - Referrer to Page A (Headers option maybe)
HTTP Request - Page B Permission Verifier
Regular Expression Tester - extract permission validation value
If Controller - If user has permission to Page B
HTTP Request - Page B
Regular Expression Tester - Referrer to Page B (Headers option maybe)
Http Request - Logout
HTTP Header Manager - Referrer: ${referrer}

Related

Can we simulate real time traffic on e-commerce application thru jmeter with users drop at each steps

Eg : Let say we have following rest API steps in my flow:
1. Login
2. Addtocart
3. Increment item qty
4. Applying voucher in cart
5. Updating shipping address
6. Placing order.
Now in above flow, let say I want to start with 300 concurrent users and at every step I want 5-10% users drop like:
1. Login - 300 users will do
2. Addtocart - 270 users will do
3. Increment item quantity : 243 users will do
.
.
.
And so on
Create multiple thread groups. For example:
Thread group 1- Login
-Login Request
Thread group 2- Addtocart
-Addtocart Request
Thread group 3- item quantity
-item quantity Request
Now you can set manually the number of threads for each thread group. Set it manually as 300,270 and 243 and corresponding ramp up time.
Only thing you need to be taken care is passing the cookie from login thread group to the other two thread group.
For this Add a beanshell postprocessor as a child of login request and add the following code
props.put("yourcookiename1","${COOKIE_yourcookiename1}");
props.put("yourcookiename2","${COOKIE_yourcookiename2}");
props.put("yourcookiename3","${COOKIE_yourcookiename3}");
Now add a Beanshell PostProcessor as a child of addtokart request and increment qualtity request and add the following code:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie("yourcookiename1",props.get("yourcookiename1"),"abc.com","/",false,0);
manager.add(cookie);
Cookie cookie1 = new Cookie("yourcookiename2",props.get("yourcookiename2"),"abc.com","/",false,0);
manager.add(cookie1);
Cookie cookie2 = new Cookie("yourcookiename3",props.get("yourcookiename3"),"abc.com","/",false,0);
manager.add(cookie2);
This will pass cookie to your 2nd and 3rd request which is under different thread groups.

JMeter test fragment use case to generate group name in jmeter result

I have a Test Plan that contains the following:
Test Fragment
Simple Controller with label "User Login"
HTTP Sampler with label "User Login to website"
ThreadGroup 1
Module Controller to call Test Fragment - Simple Controller with label "User Login"
TG1 - Sampler 1
ThreadGroup 1
Module Controller to call Test Fragment - Simple Controller with label "User Login"
TG2 - Sampler 1
My problem is jmeter generate the following in jtl file
User Login to website
TG1 - Sampler 1
TG2 - Sampler 1
I can't differentiate "User Login to website" call from each Thread Group.
How to configure jmeter to generate test result for each Thread Group despite using the same sampler from Test Fragment?
something like
TG1 User Login to website
TG2 User Login to website
TG1 - Sampler 1
TG2 - Sampler 1
You can add to User Login Name request the thread group name by adding the following __groovy function:
${__groovy(ctx.getThreadGroup().getName())}
This will group user login per thread group in results

How to Control Time Expires of a 1 session in Classic ASP?

I have 3 sessions -
1- USER
2- LANGUAGE
3- COUNTRY
When session expires - user is redirect to login and receive a message: "You are disconnected by inactivity"
Its ok. but..
MY ISSUE:
Because I lost session - I lost ALL 3 Sessions - and I don't know the LANGUAGE and COUNTRY of the user.
Then I Always print an English alert (default language)
What I want:
A way to control de timeout of each session. With this I can expires User Session first - and get the other two parameters to print the right language.
Is it possible?
I know how to expires - but ALL sessions..
tks!
Use cookies, so you can control the time, even if the user closes the browser
Response.Cookies("name_cookie")("language") = 1
Response.Cookies("name_cookie")("country") = 1
Response.Cookies("name_cookie").Expires = now + 365

Jmeter user session wise different data set

My test plan is as following
- Test Plan
- Thread Group (No of Threads: 4)
- HTTP Request Defaults
- HTTP Cookie Manager
- CSV Data Set Config(Login Information) [4 user login]
- Simple Controller
- HTTP Request(GET: Open Login Page)
- HTTP Request(POST: Login auth)
- Loop Controller
- CSV Data Set Config(Operation Information) [8 operation data]
- HTTP Request(GET: Open Operation page)
- HTTP Request(POST: Commit Operation)
- HTTP Request(POST: Logout)
In this plan suppose I provide 4 users and 8 operation data.
What it doing is running 8 operation for 4 users each in total of 8x4=32 operations.
How could I make this as following
1st user will do 2 operations
2nd user will do 2 operations
3rd user will do 2 operations
4th user will do 2 operations
I want to provide user session wise different operations that 4 users will do number of transactions but the transactions will not be same.
How can I achieve this?
If I'm getting your test scenario correctly you can just set the "Sharing Mode" of your CSV Data Set Config (Operation Information) to Current Thread Group.
Current thread group - each file is opened once for each thread group in which the element appears
If you want more precise control I believe Switch Controller is what you're looking for, using it you can select which user will go for which execution branch.
See Running JMeter Samplers with Defined Percentage Probability article for more information.
As requested, I am posting my solution. Below is the test plan story.
Test Plan
Thread Group
I used only 1 thread in my thread group and 4 in the loop count as shown below.
Loop Controller
CSV Config for the both the files
Output

JMeter test simultaneous users with sequential requests

I have a problem. I would like to do sequential http request with JMeter but with simultaneous users.
Example : I've got 100 users and at the same time they try to do :
Login
Do stuff 1
Do stuff 2
Logout
In this order.
In my results I don't want to have
User 1 do :
login
stuff 1
stuff 2
logout
after that the
user 2 login
stuff 1
stuff 2
logout
I would like to have at the same time User 1 and 2 try to login after that they do their stuff and logout.
So, in my results I can have this example :
Login user 1
Login user 2
Stuff 1 user 1
Stuff 2 user 1
Stuff 1 user 2
Stuff 2 user 2
Logout user 2
Logout user 1
Thanks,
Marcel
Take a look at Synchronizing Timer, I believe it is exactly what you need.

Resources