JMeter web page test - Your session expired because of inactivity - jmeter

There will be two actions once we click on log in button
login page action
dashboard action
Part of JMeter
login page action got success.in the continuation
dash board action got failed saying
"text":"Your session expired.","explanation":"Your session expired because of inactivity."
Can anyone help me please..

Your SUT is likely to have some form of verification mechanism which checks user session by verifying parameter(s).
Well-behaved test should do exactly what real browser does, to wit:
Open login page
Perform login
Open dashboard
and your job is to ensure that requests which are being triggered by JMeter are 100% match to the requests which are being sent by the real browser.
Try adding HTTP Cookie Manager to your Test Plan, if your SUT checks the cookie - that should be enough. If not - most probably you will need to perform correlation - the process of extracting dynamic parameters from previous response using JMeter Post-Processors, saving them into JMeter Variables and replacing hard-coded (recorded) values with these variables.

Related

Jmeter login script

I am using Jmeter for testng load balance of website.I written a script to test the scenario like to make the user to login into the website and able navigate the user to the dashboard where he can see the recent data by consuming the protected calls.Here i am able to pass the user login scenario but the jmeter showing fail errors regarding the protected calls.When i am searching the url thing whcih is given by jmeter i able to understand that teh protected calls need user credentials to consume data but it fails due to absence of user login things.
Here i am able to pass the user login scenario
are you sure? If JMeter reports the HTTP Request sampler as successful it doesn't necessarily mean that the login will be successful, it might be the case your application responds with status code 200 and some error message explaining why the login has failed and JMeter automatically treats HTTP Status Codes below 400 as successful.
Try inspecting request and response details using View Results Tree listener which has HTML and Browser modes and double check that you're able to login.
If yes - you might need to add HTTP Cookie Manager or perform the correlation of the authorization header in the HTTP Header Manager for the "protected calls" or something like this
If no - you will need to amend your script so login will be successful. In order to avoid such situations in future you might want to add Assertions to your test plan to ensure that JMeter is doing what it's supposed to be doing

Keep session with Cookies in Jmeter

I am trying to run a simple test in jmeter but i am stuck. The steps are:
Log in
Set the Cookie Manager
Access the landing page
The first 2 steps are successful, but i get status 403 "errorId":"AUTHENTICATION_REQUIRED" on the 3rd step. My guess is it is not getting the session from log in, but everything i 've tried hasn't worked. Here is my test plan:
Any suggestions?
JMeter's HTTP Cookie Manager obeys JMeter Scoping Rules, so if you put it as a child of the Setting Cookies request it will be applied to that request only, therefore cookies will not be available to the Landing Page
Try moving the HTTP Cookie Manager one level higher so your test plan would look like:
You should be able to see which cookies are being received and sent out using View Results Tree listener

Logout not working in Jmeter script

I have been using JMeter for a while and I am facing a problem in particular related to logout. I am using the below script -
TestPlan
HTTP Cookie Manager
HTTP Request Defaults
ThreadGroup - (scheduled for half and hour)
Once Only Controller
HTTP Request - login
Loop Controller - (forever)
HTTP Request 1
HTTP Request 2
....
HTTP Request 13
tearDown Thread Group
HTTP Request - logout
But the problem here is that even the logout response looks good , the user used for JMeter script login is still actually not logged out. (that i can monitor as as Admin)
Most likely your "Logout" link just clears user's cookies via JavaScript. As per Apache JMeter project main page:
JMeter is not a browser. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever viewed at a time).
So Logout event can be simulated in JMeter by clearing cookies - see "Clear cookies each iteration" box in the HTTP Cookie Manager
NB: Iteration in the HTTP Cookie Manager (as well as in HTTP Cache Manager, etc) is something which is being defined and incremented at Thread Group level, loops triggered by Loop Controller, While Controller, etc. are not considered as "iterations"
It it also possible to clear cookies programatically i.e. from Beanshell Sampler

Jmeter- Unable to understand result for the workflow

My website workflow is as follows:
User Name-->Password-->Click on login button-->Click on Report menu(Daily Transaction)--->Select date and device in report-->Click on Generate button.
Now I want to check load testing for this scenario that if multiple users gets logged in and access the reports, how my website will act?
I have created csv file for multiple user login with report data. But not able to understand the output coming. It is displaying Login request twice i.e. Login request and under daily report request it is again displaying login request. I have created Login request and report request separately.
In result I am not getting why it is displaying login request again under daily report request.
I believe that it is due to 1st login request failure as daily report request is not available for non-authenticated user. I would recommend taking the following steps to resolve your issue:
Add a HTTP Cookie Manager to your Test Plan. It will automatically care about handling cookies and hopefully will be enough to let you to proceed.
If not - record your login request several times and inspect recorded requests to see if there are any differences. If they are - you'll need to provide some mandatory dynamic parameter along with credentials. In that case test Scenario skeleton will look as follows:
GET request to Login Page
Extract dynamic parameter value
POST request to Login Page providing username, password and dynamic parameter name/value pair
See ASP.NET Login Testing with JMeter guide for more details on dynamic parameters extraction and usage bits, even if your application is not ASP.NET based it should still give you a clue on what needs to be done.
If you are using Transaction Controllers this can yield misleading results like you are seeing.
For example, take the following:
Transaction Controller - Name "Login"
HTTP Sample - Name "Login"
If "Generate Parent Sample" is selected on the transaction controller, you will only see the Transaction Controller in your results. If this option is not selected, you will see both the HTTP Sample AND the Transaction Controller in the result set.
Also, please note that the "Parent Sample" time is recorded as the TOTAL time taken to do all requests in the transaction end to end!! In almost all cases this reports inaccurate times because a real web environment has asynchronous calls.
For this reason it is strongly encouraged to avoid transaction controllers. In one case you report end-to-end time for all samples which is incorrect, and the other alternative is to report the transaction controller AND the sub-samples, which in turn makes your test report the incorrect rate of transactions.

Session Expired Response in JMeter

I am testing particular application using JMeter 2.9.There My test plan is Thread group--> Transaction Controller.Inside that various recorded requests are there.I am using HTTP request defaults,HTTP Cookie manager and HTTP header manager,and a view result tree for validation.I found one token i.e. CSRF token to be correlated and I did correlation.But for a particular request I am finding "Session expired..Login again" response much before the logout request.My transaction flow is to Login--> Search a content-->Logout.
Please help me finding a solution.
Try put the element: HTTP Cookie Manager in Thread Group, first item.
the problem can be in the following areas:
-you were redirected automatically instead of following redirects
-login hasn't succeeded
-the session id has not been successfully passed on to the request after login
The JMeter documentation states this:
I've set up JMeter to sample the same URLs as my browser, why is JMeter not seeing the same responses?
There are various different reasons for this:
Cookies - make sure you added a Cookie Manager. Browsers process cookies unless you set them up otherwise, but JMeter does not process cookies unless you add a Cookie Manager.
User-Agent - the User-Agent is a header that is sent by browsers; it identifies the browser type. Some servers are sensitive to this setting and generate different results for what they think are different browsers. The Header Manager is used to add headers such as User-Agent.
Hidden fields - if you did not use the JMeter Proxy (or other application) to record the test plan, then it is easy to miss hidden fields from forms.
Dynamic field names/content - some servers use varying names for fields. So although the test plan may be correct at the time of creation, it does not work when replayed.
URL rewriting - TBA
from http://wiki.apache.org/jakarta-jmeter/DifferentBehaviour

Resources