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

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

Related

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

Modify the resource path for a sub-sample in JMeter

I have recorded a user journey in JMeter (using AngularJS). When I click a link that spawns a GET request to a page, in-turn it spawns additional sub-requests to some page resources (images).
In Short:
Test Plan
-- Thread Group
---- Transaction Controller
------ HTTP Request (Main sample)
Here the main sample triggers additional sub-samples for resources and they fail due to path issues however this works manually using a browser.
I am in need to change the path of the sub-samples or not fail on a 404 for these sub-samples.
The fact you are getting different results in browser and JMeter indicates that your JMeter test is not well-behaved as it doesn't replicate browser requests with 100% accuracy therefore your load test doesn't make a lot of sense as "good" load tests must represent real user sitting behind real browser as close as possible. I would recommend comparing requests which are being sent from browser and JMeter with a sniffer tool like Fiddler or Wireshark, identify the differences and amend JMeter configuration so JMeter-driven requests would be exact replica of browser-driven ones (apart from dynamic parameters)
For the time being I can tell you only how to convert failed sub-samples into successful ones.
Add JSR223 PostProcessor as a child of your main request
Put the following code into "Script" area:
prev.getSubResults().each {
it.setSuccessful(true)
}
That's it, the above Groovy code will mark all sub-samples as successful no matter of original status (the response status code, message, body, etc. will remain original, JMeter just won't consider them as failed anymore). See Apache Groovy - Why and How You Should Use It article to learn more about using Groovy scripting in JMeter tests.

Liferay p_auth correlation

In my application the value of p_auth is dynamically changes
I tried to handle it by correlation and it seems fine to me but not getting succeed.
I am attaching some screenshots , Please help me to identify where I am wrong
enter image description here
enter image description here
P_AUTH is Liferay authentication token which is used for CSRF protection, it can be handled in 3 easy steps:
Design your test scenario as follows:
Open login page
Extract p_auth
Pass extracted values from step 2 into login request
Step 2 in details:
If you look into response text from step 1 you will see p_auth in the response body:
In order to extract it into a JMeter Variable add Regular Expression Extractor as a child of the 1st request and configure it as follows:
Reference Name: anything meaningful, i.e. p_auth
Regular Expression: p_auth=(.+?)"
Template: $1$
Usually it is not required to extract formDate parameter, I usually substitute it with ${__time(,)} function
So request itself looks like:
To double check we have successfully logged in - check out Response Data tab of the last request which opens user dashboard:
See How to Load Test CSRF-Protected Web Sites article for a little bit more detailed information on bypassing CSRF protection in JMeter tests.
P.S. I see HTTP Header Manager in this screenshot. If it is something you got during recording - REMOVE IT as it can contain hard-coded irrelevant headers which may harm or at least review headers and leave (or correlate) only those you need

Jmeter: Issue with Response Data (HTML) and Is my script Functional?

I am using Jmeter(2.3.2) to create script for one of my application with a scenario which has flow for 4 to 5 pages. I have recorded the script using HTTP Proxy Server. The scripts has been generated successfully under Thread Group >> Recording Controller.
After running the scripts (Threads- 1, Ramp Up period - 1, Loop Count - 1 ), below are the observations I noted in View Results Tree:
The Result Tree view shows all as Checked(Green) - OK
The Sample result for all screens shows Error Count as 0 - OK
But in the response tab when I try to view the results by using 'Render Html' response data - the response data shows the same response for all the requests.
I am getting the response data of the first request for all the other requests.
I am not sure, whether the Jmeter script generated is functional or not? What is the cause for getting the same response data for all the requests?
Please, can anyone let me know what may the issue?
I bet that the same page you're observing is a kind of login page or dashboard which is accessible by unauthenticated user.
First of all make sure that you have HTTP Cookie Manager added to your test plan. It represents browser cookies and deals with user sessions and cookie-based authentication.
If it doesn't resolve your issue the problem is bigger and you will need to do some extra stuff. Modern web applications use multiple mechanisms of current state of things storing and managing, security enhancements and so on. From JMeter's point of view it results in dynamic mandatory parameters. The process of these dynamic parameters extraction from previous request and adding them to next request is called "correlation". So you need to do the following:
Detect which parameters being sent by a recorded script are dynamic. The easiest way is to record the same scenario several times and inspect request bodies to see what is being static and what changes.
Once you figure out which parameters are "interesting" you need to locate them in the first response body/headers/etc.
As soon as you have identified what necessary parameters are and where they live you need to use one of JMeter's PostProcessors to extract required values from previous response and save them to JMeter Variables
Once you have a JMeter Variable it can be used wherever required.
Depending on response data type the most commonly used JMeter's Post Processors which provide correlation capabilities are:
Regular Expression Extractor - the most commonly used test element which covers >90% of needs.
XPath Extractor - better to use against XML data i.e. for testing SOAP Web Services.
CSS/JQuery Extractor - when you need to fetch something from complex HTML where Regular Expression Extractor is useless.
So for putting everything together loog for "jmeter correlation" in your favorite search engine or see ASP.NET Login Testing with JMeter guide.
First JMeter 2.3.2 is WAY TOO OLD (10 years old), upgrade to JMETER 2.11.
Second, Jmeter cannot guess that the response if KO if the returned code is 200, so you need to add Response Assertion that will check for some text you expect in the page.

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