Jmeter cookie handling while page redirect - jmeter

Scenario:
Login (URL 1)
Launch link from landing page
Newly launched link (URL 2)
URL 1 and URL 2 has same domains but different sub-domains.
Have added HTTP Cookie Manager
When I am running my script using Jmeter 3.2 which has only HC4CCookieHandler
Login is passing
Launching the link which has different subdomain is failing, and on verifying there are No Cookies added in the request, here the session ID and other cookies should have been added to the request.
Can some one please help here?
Also added Beanshell post-processor to extract cookies from logon response and added as pre-processor to the redirected request, but is giving error.
Error: jmeter.util.BeanShellInterpreter: Error invoking bsh method:
eval Sourced file: inline evaluation of: ``import
org.apache.jmeter.protocol.http.control.CookieManager;

The fact you don't see all the cookies might indicate problems with the cookies. You can enable debug logging of the HTTP Cookie Manager in order to see what's wrong.
Click HTTP Cookie Manager
Click "Help -> Enable Debug" in JMeter's main menu
Observe CookieManager-related messages in jmeter.log file
By default Cookie Manager doesn't store "invalid" cookies (domains mismatch, expired already, etc.), if you are absolutely sure your application acts as it should - you need to "tell" JMeter to store this cookie in any case, you can do it by either adding the next line to user.properties file (lives in JMeter's "bin" folder)
CookieManager.check.cookies=false
JMeter restart will be required to pick the property up
Alternatively you can pass the property via -J command-line argument like:
jmeter -JCookieManager.check.cookies=false -n -t ...
In this case restart will not be required.
In case of manual cookie management in particular and when it comes to using JMeter in the most efficient way in general it is better to avoid scripting where possible. For example you can extract cookie(s) you need from Set-Cookie response header(s)
using Regular Expression Extractor. In case(s) when you have to go for scripting make sure you use the most performing language (which is Groovy)

Related

JMeter: CSS Extractor transfers wrong __VIEWSTATE-value to the Login Page

I am trying to log in into a ASP.NET website and can not transfer the right __VIEWSTATE to the Login Page. I am trying for hours now and cant seem to find what Im doing wrong.
Problem:
I have a start page where the VIEWSTATE is created and have to pass it to the login page where i then
First I added a CSS Extractor with following configuration:
[CSS-Config][1]
[1]: https://i.stack.imgur.com/rArRE.png
Then I referenced the variable in the next sampler:
[Login Page Sampler][2]
[2]: https://i.stack.imgur.com/jhroP.png
When I run the Testplan I get a different __VIEWSTATE in the Login Page.
The ViewState from Debug Sampler - Tree View Listener:
[Debug Sempler][3]
[3]: https://i.stack.imgur.com/gwXwb.png
Listener-Tree Start Page:
[Start Page][4]
[4]: https://i.stack.imgur.com/FP0Mr.png
Listener-Tree Login Page:
[Login Page][5]
[5]: https://i.stack.imgur.com/6p0dV.png
It's hard to say what's going on without seeing your test plan, most probably you're getting different values for your ${View} variable due to this CSS Selector Extractor scope including more than one HTTP Request sampler so the value gets overwritten somewhere somehow so first of all I would recommend getting familiarized with JMeter Scoping Rules concept. In short words:
If you place the Post-Processor at the same level with several samplers - it will be applied to all the samplers
If you make the Post-Processor a child of a single sampler - it will be applied to this sampler only
You need to correlate this __VIEWSTATEGENERATOR value as well
Make sure to add HTTP Cookie Manager to your test plan and if you did already double check that it sends all the cookies which are being sent by the real browser

Unable to pass Jmeter recording test when running the test in real website- one section get fail?

I want to do load test as well as performance test a website and I have recorded user step by step action through jmeter recording by proxy setting. And when I run this recorded test it gets passed all the sections except one section.
During recording steps, it gets filled all the required fields like POST, GET, PATH etc by default as well as like token, session id etc in the HTTP header manager. When user login again its get unique session id and token through Regular Expression Extractor. But my test gets failed when the user wants to accept a task it says unauthorized. I have attached screenshot.
This image showing all the steps user will do from login to logout.
Here steps 2.9 section gets fail.
Here its showing the response from the server.
Please let me know where am I doing wrong.
There are multiple possible issues with your test:
Location of the Regular Expression Extractor and other Post and Pre-Processors. According to JMeter Scoping Rules they are applied to all your Samplers so please double check if this is something you're looking for. If you want to apply the Post-Processor to a single sampler - you need to move it to be a child of the particular sampler
Since JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so consider converting your Beanshell test elements into JSR223 ones
Since JMeter 3.0 there is JSON Extractor which you should be using instead of the plugins
In general HTTP status 401 means Unauthorized so double check that your test is doing what it is supposed to be doing using View Results Tree listener. You might also want to double check JMeter Variables values using Debug Sampler as it might be the case that the variables are being overwritten with something you don't expect due to the aforementioned Scoping Rules potential issue

Header Manager and Recording Controller

In my test scripts, I use a header manager that is shared at a thread group level, and then each sampler has it's own header as well for things that change (referrer, certain pragmas and cache-control) from request to request. I do this for ease of control e.g. so I can easily change the user agent for all requests.
I use the proxy and a recording controller to make the majority of my scripts, and I have set a header manager as a child of the recording controller - I have also tested this by setting a header manager inside the proxy element, but neither of these work as I want.
What it is doing is adding in a full set of headers from the browser, and not just those missing or different than what I have specified in the header manager.
Am I missing something, or is there even a way to do what I am trying to do?
I am using jmeter 2.6.
As others have pointed out, this doesn't happen yet in Jmeter. I am using 2.7 and see the same behavior.
I believe the original intent of the HTTP Request Defaults and HTTP Header Manager was to ease the task of developers creating scripts by hand. With the increased usage of the HTTP Proxy Controller, the application of the the above two elements needs to be extended to the Proxy Controller as well for recording.

JMeter is not able to record and play "Checkbox" in webpage properly

In one of my performance test scenario, user has to select one check box and then click on save button , I am able to record the scenario but unable to play. Steps are as follows:
Log in to the application
Go to Page 1 and click on any “Check box” and then click on save button.
For one user script was able to record but while running for multiple users I found that script is not checking the “Check box”. Does any body has any clue on this ?
Jmeter DOES NOT support Javascript.
As per Jmeter FAQ:
JMeter does not process Javascript or applets embedded in HTML pages.
. . . If the page uses Javascript to build up a URL or submit a form,
you can use the Proxy Recording facility to create the necessary
sampler. If this is not possible, then manual inspection of the code
may be needed to determine what the Javascript is doing.
JMeter is a tool for testing server code, not the client one. Both
recording and playback happens at the HTTP layer.
What you can do in your case is:
use any traffic inspector tool to record http request (upon "Save");
analyze request and its parameters sent;
setup request manually in jmeter.
Check/unchecking check box in your scenario doesn't generate any traffic itself BUT sets the value of request parameter sent along with further http request upon further "Save".
You have to set value of this param manually to the value which is equivalent to "checked" state of check box.
Jmeter does not recognise the elements written in javascript.
Try this:
Open Blazemeter
Go to advanced options
Select Cookies and Javascript Option under Request to Record
This solution worked for me.

jmeter regarding performance and load testing

Let me describe the issue which i have been facing.
i want to do performance and load testing on our internal website. which has login and other functionalities.
the issue i am facing that when i hit 12 or any number of request using http sampler then i am getting same response from all the 12 request. But actual scenario is that webpage displays different data for different page.
I checked using firebug and everything is working fine over there using correct response from request but when i use jmeter i am using same response from every request.
Please let me know if anybody had faced same kind of issue of is there anything i am doing wrong in configuring script.
Try to add HTTP Cookie Manager to your test-plan to the root (Test Plan) node or to the Thread Group node.
As per jmeter documentation:
The last element is a HTTP Cookie Manager. A Cookie Manager should be
added to all web tests - otherwise JMeter will ignore cookies. By
adding it at the Thread Group level, we ensure that all HTTP requests
will share the same cookies.
Ensure that parameters values that are dynamic are not hard-coded (after recording jmeter scripts, for example): no hard-coded JSessionID values in your HTTP requests, e.g..
Ensure you don't miss any necessary params in your HTTP requests.
JMeter does not process Javascript or applets embedded in HTML pages.
Your problem may be caused by this feature.
As per jmeter documentation:
JMeter does not process Javascript or applets embedded in HTML pages.
JMeter can download the relevant resources (some embedded resources
are downloaded automatically if the correct options are set), but it
does not process the HTML and execute any Javascript functions.
If the page uses Javascript to build up a URL or submit a form, you
can use the Proxy Recording facility to create the necessary sampler.
If this is not possible, then manual inspection of the code may be
needed to determine what the Javascript is doing.
I would also recommend your to look first into Jmeter reference before further scripting activities - this may prevent from some faults and frustration.
At least these:
Building a Test Plan
Elements of a Test Plan
Building a Web Test Plan
Building an Advanced Web Test Plan
Hope this helps.
I would suggest - Use Jmeter's Regular Expressions. You may be able to resolve this issue with RegEx. Post using regex, use 'View Results Tree' listener to check if you are getting apt response for each of your threads.
You can also analyze your results using Blazemeter's listener that gives you more insights into your test.

Resources