Jmeter Log On in SAP CRM web client Error - jmeter

I used Jmeter's HTTP(S) Test Script Recorder to record the Log in in SAP CRM Web client. I configured HTTP Cookie Manager using the cookies that I saw in browser developer tools ( MYSAPSSO2, Session ID, Sap-usercontext).
In the same recording test I filled some fields in SAP. I stopped the recording test.
I did it multiple times to see what parameters were dynamic and I realized that wfc-secure-id and C5_confighash and c7_confighash were dynamic. So I used regular expression to extract the dynamic values and I applied it in the requests where I filled the fields.
In View Results Tree I can see the HTML response in the Requests' response bodies that the log in was successful and the fields were filled. I also checked the SAP sessions metrics that the users are logging in.
After the successful login I went and did some recordings of a User roaming around inside the web client performing some operations and saving the results. I changed the dynamic values to fit the previously values I obtained in the login process.
The issue lies in the fact than when i went back to JMeter to do a test run, I get a logon error on the response header between the login and the new recordings. The response body of the new recordings also return empty.
I'm thinking that between the recordings, jmeter is losing the user session information
How can I connect the new records with the log in record?

You should not be hard-coding cookies in the HTTP Cookie Manager.
JMeter doesn't record cookies
headers.removeHeaderNamed(HTTPConstants.HEADER_COOKIE);// Always remove cookies
hence you should not be manually adding the cookies you see in browser to the HTTP Cookie Manager, adding an empty HTTP Cookie Manager should be enough to let JMeter automatically take care of incoming cookies.
If you don't see the cookies being added to the request(s) it usually means that:
Your HTTP Request sampler is not configured properly, i.e. "Server Name or IP" field is empty
Your server is not configured properly (i.e. it returns cookies which doesn't comply with the standard hence JMeter fails to add them)
The steps you could take are:
Enable debug logging for the HTTP Cookie Manager by adding the next line to log4j2.xml file:
<Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
Use less-restrictive cookie policy, i.e. netscape
Add the next line to user.properties file:
CookieManager.check.cookies=false
Check out HTTP Cookie Manager Advanced Usage - A Guide for more information on JMeter's HTTP Cookie Manager usage/troubleshooting

Related

Jmeter cookie manager not renewing cookie with each loop

I am fairly new to jmeter and currently I am using jmeter to create a test plan with Prometheus plugin, we have various endpoints that needs to be probed, our application use a cookie that refreshes every day so the cookie value changes likewise. Once the jmeter runs on the host, it gives 200 response code but after a day, when the cookie refreshes, we start seeing 401s for all the endpoints, my guess is the cookie is not being generated properly. I am using HTTP cookie manager in the jmeter which supposedly gets the cookie automatically, and I also have selected clear cookie each iteration but it doesn’t seem to work.Please help.
HTTP Cookie Manager does really clear cookies but it applies only to Thread Group iteration, other Logic Controllers like Loop Controller or While Controller won't trigger cookies renewal.
You can check what exactly is happening by enabling debug logging for the HTTP Cookie Manager: add the next line to log4j2.xml file:
<Logger name="org.apache.jmeter.protocol.http.control" level="debug" />
and upon JMeter restart the jmeter.log file will contain information regarding incoming and outgoing cookies.
It's also possible to force clear cookies, it can be done by adding a JSR223 PreProcessor as a child of the very first HTTP Request sampler and putting the following code into "Script" area:
sampler.getCookieManager().clear()

How to save cookies in jmeter recording and replay

Here i have two questions regarding capturing the cookies through JMeter. I am using JMeter recording to capture the web browser flow . And i have added Cookies Manager under the Test plan (common for all requests) Below is my flow :
launch >select Providers >sign-In
While recording it is capturing the cookies properly . i am able to see in the "Request Data" in "View Results Tree" . But while trying to replay i am not seeing the cookies in the results.
Please let me know if i am missing some settings here.
How this will work when we increase the no of users and run.
Thanks In Advance.
JMeter doesn't record cookies, if you add HTTP Cookie Manager to your Test Plan it will automatically extract the cookies from the application's Set-Cookie response header, parse them, validate and send with Cookie header during the next request.
If you cannot see any cookies the reasons could be in:
Cookies are invalid (i.e. expired, not matching the domain/path)
Your test fails somewhere somehow, i.e. your sign-in request fails because you haven't implemented correlation of the dynamic parameters
Inspect response details using "Response Data" tab of the View Results Tree listener and ensure that your test is doing what it is supposed to be doing as it looks like it doesn't go further than first page in your case

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

Append cookies and sending to next request using cookie manager in jmeter

I am doing load test for my application. For login i am getting set-cookie in response headers. Is it possible to append all cookies using cookie manager and sending it in request header for another request
Just add cookie manager to you thread group.
Jmeter will automatically transfer the cookies to the further request correspondingly
Add HTTP Cookie Manager to your Thread Group, it should handle cookies automatically.
If it doesn't pick up all the cookies, there should be an issue with one or more cookies, i.e. Domain or Path mismatch or expiration date is in the past or whatever. If this is the case and you still want JMeter to consider the invalid cookies you can try adding the next line to user.properties file (located in JMeter's "bin" folder)
CookieManager.check.cookies=false
Given this property set to false JMeter won't check cookies before storing them and you should see "missing" ones, however I would recommend raising a defect against your application as the fact you are not seeing the cookies added by the HTTP Cookie Manager indicates that something is wrong with them

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