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

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

Related

Facing issues in __eventvalidation and __viewstate in jmeter

i have a scenario, as given below
once the user navigating to planning page and
clicks on a menu,
it will open the lists of recipes in week wise.
if the users wants to add a recipe for a particular, it has an option to click on '+', which will open a popup window which has all the recipe details available.
I have recorded the scenario using JMeter and it has the dynamic values like __VIEWSTATE and ___EVENTVALIDATION etc., and correlated them as well.
But at the 4th step, in the jmeter instead of proper response body and the below message is displayed.
1|#||4|137|pageRedirect||%2fPerfTesting%2fError.aspx%3faspxerrorpath%3d%2fPerfTesting%2ffi-FI%2fDefault%2fKAXXILA%2fPlanning%2fPlanningMenuWeekView.aspx|
Any suggests
Make sure to add HTTP Cookie Manager to your Test Plan
Make sure that your correlation really works, i.e.
associated JMeter Variables are there
they have correct values (like you extracted the dynamic parameter fully)
depending on your application and extra step might be required like URL-encoding the parameter or vice versa
You can use Debug Sampler and View Results Tree listener combination in order to check these variables
Use an external sniffer tool like Wireshark or Fiddler to capture the requests from JMeter and the real browser, the requests must be exactly the same including:
URL
Headers
Request body
all the dynamic parameters must be properly correlated. Given you will send the same request you should get the same response

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

Getting js objects from browser console and Jmeter

I'm working on a new project, the client is a bank and I need to perform performance tests, I wanted to use jmeter as a main tool, but I found a problem, most of the pages ask for a token, so I need to catch token and set this to the next POST request in order to login and continue through the different page forms, the problem is that this token is generated by a javascript, so is not returned in any GET response body; I can just get it by console's browser, because this token is generated in a javascript object.
I've tried with postProcessor elements as regular expression extractor, JSR223 PostProcessor (I'm not a pro with) and finally with Webdriver Sampler, this last one is working, but I had to import some Java classes, did some modifications, etc; but I this is not an option, because if I perform the test with several virtual users the machine is going to run out of resources.
I was wondering if you have faced with something similar, if so, could you please make me a suggestion?, maybe perform tests with a different tool, framework...
Thanks in advance.
First of all I would recommend looking into the response more attentively as the token might be coming as a Cookie or a Header, if this is the case you should be able to extract it using HTTP Cookie Manager or Regular Expression Extractor correspondingly.
If the token is generated via JavaScript code you can re-implement the logic using Groovy language and use vars.put() function in order to store the generated value into JMeter Variables. If you cannot come up with the relevant Groovy code - update your question with the JavaScript code snippet and most probably we'll be able to help you with converting it into Groovy and exposing to next Sampler(s)

Error while executing checkout script in JMeter

[404-Not found]
Hello All,
I'm running one script having Checkout functionality but my script gets fail at particular page instance giving me "404 - Not found" error in logs.
But while executing manually I'm able to go to the page successfully.Below is the error message. Do i need to pass cookies in the same while execution.
Any help will be appreciated
Most likely this is due to missing or not properly working correlation. You can record the test scenario using HTTP(S) Test Script Recorder but it will be only a "skeleton" of the test containing hard-coded values like IDs or URLs or whatever.
So given you checked something out and recorded the relevant request(s) next time you will try to replay the recorded script you will get an error as the item has already been checked out, so basically you need to find another one to work with.
Normally the situation is worked around as follows:
Record the test 2 times
Identify request parameters which are changing
Using JMeter PostProcessors (the most commonly used is Regular Expression Extractor, however it may vary depending on your response data nature) convert hard-coded recorded values into JMeter Variables
Use Debug Sampler and View Results Tree listener combination to inspect:
JMeter Variables values
Request details
Server responses

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.

Resources