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

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.

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

Can JMeter do automation testing like Selenium can do?

i am still new to JMeter and i was assigned to a work that I will need to use JMeter to perform automation testing. The idea is to write script using JMeter and run the script to fill in the forms in the website. I was curious that can JMeter use different data from the database to fill in the form of the website everytime it execute?(unique data for every user)
I have followed this tutorial (https://www.blazemeter.com/blog/fill-forms-and-submit-with-jmeter-made-easy/ ) and it succeed, however, when i try to change the parameter name (to some other names that do not matches the field name found in the inpect mode), it still works. So i was wondering how JMeter knows where to put in the parameter even i have change to a wrong field name?
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).
Browsers don't do any magic, they execute HTTP Requests, wait for response and render it. JMeter in its turn can execute the same HTTP requests so traffic would be the same, however it will not render the response, but rather measure the time and collect some more metrics.
If you change the names of the inputs in the form most probably the request will be successful, to wit you will get HTTP Status Code below 400 hence JMeter will mark the result as "green", however if you inspect the response using View Results Tree listener you will see that the form is not filled and/or you still at the same page.
If you want to use JMeter for checking the data returned by the application you're testing consider using JMeter Assertions to test presence of expected values, absence of errors, set response time thresholds, etc.
You can automate the form submission or order placement usin JMeter. You can JMeter for API testing as well by adding assertions. But the main purpose of the JMeter is to test the performance of the application. Its not like selenium which performs actions on the browser whereas JMeter sends the request in various protocols to relevant server and can also simulate many users at the same time.
If you want to do extensive automation testing,JMeter isnt the ideal tool for that.
You can use webdriver sampler to run the selenium with jmeter. It requires to configure sampler and browser config which are plugin and can be downloaded using plugin manager.
For more info:-https://www.blazemeter.com/blog/jmeter-webdriver-sampler/
Now, without the plugin it is working on protocol level and not on the frontend as pointed out in the above comments.
So, yes it can depend on which layer you want to work. It can work on frontend like selenium using the webdriver plugin and can submit the form with different data as a direct request to the server without using the frontend/GUI.
Hope this helps.
It depends on what you are trying to automate. If you plan to automate API invocation where there are some pre-requisites like grabbing tokens, cookies, session IDs from the browser, then JMeter can probably be used where existing JMeter capabilities can be leveraged using BeanShell scripting and other plugins.
But if you plan to have a full blown UI automation framework then JMeter might not be an ideal choice.

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

Unable to capture a correlate a value on a webpage using JMeter

I am currently trying to record a webpage which includes bundled.js files which are used to build the webpage.
Tool: JMeter version 3.0
The issue is that when I record the page in JMeter and replay the page response does not include all the elements and therefore I am unable to correlate the values that I need to then pass to the next call.
What I have noticed is that if I attach a view results tree to the recorder the values that I am looking for are visible. So they are being captured during the record but not visible on the response when replaying.
I am thinking that the .js files are executed during page load and therefore not being captured and all it shows is the actual
Please help
JMeter does not run client-side JS code at all. JS code is used for rendering on client side, while recording (and replay) in JMeter is done on HTTP level (communication level between client and server). It's the same level you'd see on Net tab in Developer tools of the browser. As far as recording/replay are concerned, those file will only be downloaded, and the client to server traffic they produce will be replayed. But nothing that runs purely on client side will be replayed. So if some magic/logic happens on client side (e.g. calculations, data transformation, etc within JS, which then is sent to the server), you have 2 options:
Duplicate the same logic /dynamic data using JMeter scripting functionality before sending an HTTP request. This is what most commonly people do.
Or another option is to use Selenium sampler and duplicate UI-level behavior, but that type of testing is quite limiting and only fits certain cases

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