JMeter - Should I remove Redirect from recorded script? - jmeter

I used the Blazemeter Chrome plug-in to record. When the UserID is checked, browser is redirected to another URL. This redirect is recorded in the script.
Want to ask:
I read that the redirect will occur during the UserID check if I have Follow Redirects checked ? Is this correct ? The reason I ask is that I saw some extra HTTP request generated but they are not the same URL as the redirect which was sent from the server.
So I can actually just remove the redirect URL recorded ?
Thanks.

Your JMeter test must generate the same network footpring as the real browser does
So you can use a sniffer tool like Wireshark or Fiddler to compare the number/nature of the requests which originate from JMeter and from the real browser, the requests must be exactly the same (apart from dynamic parameters which needs to be correlated)
If HTTP Request sampler redirects automatically and the next request basically duplicates the redirected one - remove the recorded one.
If automatic redirect is causing troubles and you're not able to extract dynamic elements because they're "hidden" in 2nd level of sub-results - disable redirection in the HTTP Request sampler and leave the recorded separate request which mimics redirection.

Related

Recorded script by blaze Meter & browser is showling all cookies but JMeter is not i.e. ai_user & ai_session, how do I get those cookies values?

Browser shows all cookies when we hit home request
These are the cookies that appear in browser when we execute home page 1st time, but not in Jmeter request
Its JMeter response that shows cookies
My issue is when I execute home page in browser it shows all cookies 1st time when we hit request but in JMeter home request don't show up all cookies as shown in picture.
I want cookies values i.e. ai_user & ai_session and pass them to UserSessionId & AppSessionId in HTTP request header. So how do I get those values? I already user HTTP CookiesManager in my script to handle cookies but can't get ai_user & ai_session cookies values.
Given you send the same request in JMeter as in the real browser you should get the same response so double check all the request details like:
URL
Headers
Body
etc.
Try using clean browser session or at least private mode
Look at Set-Cookie header for the first request and see if the cookies you're looking for are there. It might be the case that the cookies are being set by JavaScript and as per JMeter Project main page
JMeter is not a browser, it works at protocol level. 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 displayed at a time).
So if this is the case you will need to mimic the JavaScript code logic using JSR223 PostProcessor or just extract the values from the response if they are there using other suitable Post-Processor

Jmeter | PerformanceTesting | Cookie Manager Issue

I have recorded using jmeter and enhanced the script but facing a redirected response as below:
Object moved
Object moved to here.
I tried using Cookie manager and also correlated viewstate and viewgenerator still facing a object moved error
Try playing with "Redirect automatically" and/or "Follow redirects" checkboxes in the HTTP Request sampler
the idea is to make JMeter to behave exactly like a real browser so cross-check the requests JMeter is making with the requests from the "Network" tab of your browser developer tools
As the last resort you should be able to extract the redirection URL from the Location header using Regular Expression Extractor and configure the next HTTP Request sampler to hit this URL.

Can't get authorized response on requests in JMeter, while they have the same CSRF token and sessionID

I'm having trouble with getting my site normally loaded during the performance testing in Apache JMeter. Firstly I recorded the script (by BadBoy), containing authorization and visiting some pages, unavailable without login. Next, I exported it to JMeter, configured Regular Expression Extractor to get the csrftoken from the request right before the authorization request and it looks like it works just fine:
no errors in http-requests
But if to look at the tab "Response data" of every post-authorized request, the content isn't like correctly loaded page, it just starts page with the empty authorization form, i.e. in some way session is new though all the requests have the same session id and csrftoken in Cookie Data and in Set-Cookie (Sample result), appeared in authorization request result.
HTTP Cookie Manager is added.
Did anyone face this trouble?
UPDATE: I've conducted an experiment with transferring cookies from Chrome to Mozilla Firefox, copied 'csrftoken' and 'session id', and - voila! - it worked, I got the same authorized session in two browsers. Still have no idea what's wrong with JMeter
JMeter automatically treats HTTP Response Codes below 400 as successful, it doesn't perform any checks of response body. Most likely your Regular Expression Extractor failed, add a Debug Sampler and double check resulting variable value.
There could be also the following possible reasons:
You might need to send CSRF token in encoded/escaped form so using i.e. __urlEncode() function will be required. Or vice versa.
Application may expect the token in multiple locations, i.e. not only as a form parameter, but as an extra HTTP Header. In that case you will need to pass it via HTTP Header Manager
You might also want to try the new step-by-step debugger for JMeter to get to the bottom of the issue.
This is the default behavior of this token. 1. make sure where these tokens are passed. It might be passed multiple times. Check the header. Generally, "xref-token" is again passed.
It should be in exact format, decode it if required, also remove , or ; or /. You can also use fiddler.
The solution was found after recording a script by Blazemeter plugin in Chrome and further exporting it in '.JMX' format. Adding an HTTP Header Manager like this (with its special fields, of course) to each HTTP Request solved the problem.

browser session issue in jmeter

Iam testing an application which has the following behaviour
User1 loged into machine A using IE Then User2 cannot login into
Machine A using IE. So User2 should login from Machine B.
I have recorded the script using IE and when trying to test with 10 user load say U1 to U10, only U1 is able to login and rest all are failing....how do i simulatd the load in this case.
I checked with developers and they are not using IP address for this but using browser session for making single user logs in from a single browser.
Could you please help how do i overcome the issue and simulate the load
Try adding HTTP Cookie Manager, it can automatically handle cookies and define and maintain separate session for each thread.
If it doesn't help - inspect requests more closely with a sniffer tool like Wireshark to compare which request bits are different for different users. The possible options are:
Cookies - can be handled by aforementioned HTTP Cookie Manager
Headers - can be handled by HTTP Header Manager
Request parameters - it may be the case when server sends some parameter in the response and expects it to be present in the next request. In that case you need to extract it from the first response with i.e. Regular Expression Extractor, store it into a JMeter Variable and send with the next request.

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