Run the recorded testplan in Jmeter and verify the the entry in the Database - jmeter

Im using Jmeter and do performance testing for my web application. I record my actions in jmeter and play back the same. The testplan got run but when i verify the database manually, the new row is not created. The value got added in the existing line.Please help me out of this. I am struck in this step for 2 days

Verify if your requests includes hardcoded session's data. If your app manages sessions and you just "recorded" the actions, probably you are re-using the same session's data. Assuming there is a login page -> the requests after the login would use a session, usually returned for the login action.

As comments are not enough descriptive; posting a new answer. You can do this by using regular expression extractors, because -probably- the session info comes in the response (so extract it into a variable, by parsing the response with a regex extractor)
and then use the variable in further request/s.
This is a tricky way and need lot of work... even more if the session keep changing in subsequent responses (it usually change while moving worward through the page/app workflow), if that is the case you will need to extract the data after each request.
Please reffer to the jmeter manual for more info about regex extractors.

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

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.

Manipulate post body of httpsampler before request

I'm testing an Eclipse-RAP application with JMeter.
In RAP the client (javascript-framework in the browser) communicates with the server over a json-based protocol.
A message looks like this:
{"head":{"requestCounter":3,"uiSessionId":"832834"},"operations":[["set","w1",{"bounds": [0,0,1680,893],"cursorLocation":[1262,-1]}]]}
As you see there is a session-ID stored in uiSessionId. I extracted this id using a "Regular Expression Extractor" and stored it in a variable namedUI_SESSION_ID`.
Then i edited the raw "Post Body" of the recorded HTTP-Request:
{"head":{"requestCounter":3,"uiSessionId":"${UI_SESSION_ID}"},"operations":[["set","w1",{"bounds": [0,0,1680,893],"cursorLocation":[1262,-1]}]]}
and it works.
But i have to alter each Post-Body of each HTTP-Request which can be a lot.
After some research i thought using a "BeanShell PreProcessor" would be the right thing, but:
var sampler = ctx.getCurrentSampler();
would give me a HTTPSampler and i did not find any method which allows me to retrieve the post-body, replace the session-id with the variable and set the altered post-body.
JavaDoc: http://jmeter.apache.org/api/org/apache/jmeter/protocol/http/sampler/HTTPSampler.html
Do you know any way i can replace the uiSessionId with the variable without changing every request manually?
You don't have to. The uiSessionId header has been introduced in a milestone version in preparation for multiple browser-tab support in RAP, but it has been replaced by another mechanism that does not use this header parameter anymore.
As of RAP 2.1 RC1, the client now attaches a “connection id” to every POST request in a URL parameter cid. This parameter does not affect load tests, and you don't have to remove it from your recording. Since every jmeter thread gets its own HttpSession, it's not a problem that all threads have the same cid.
One reason for this change was the ability to load test RAP applications without the kind of problems that you've been struggling with.

Data correlation and concurrent users with Jmeter

This is Naresh. Seems this blog is really helpful for the beginners and all.
I have chosen Jmeter for Perf. testing web-based application and it is build with the environment - Microsoft dot net(Asp.net 3.5 with C#). Would Jmeter helps me?
I have done some sample recordings, for e.g login and search.
Scenario1 - Login
Here I have recorded for login and then parameterized with CSV config file.
And executed later.
As I do not much hand on exp, do I need to add anything to the above config to run it perfectly. For e.g. adding HTTP cookie manager or ?????
How to run the concurrent users?
Scenario 2:
Here, I have logged in - login.aspx is recorded
given a search - search.aspx is recorded
results will be displayed right below the search in a tabular format - (same)search.aspx is recorded
I want to run this for 100 simultaneous search(s). I understood how to pass the CSV file.
I am sure there is some thing needed to be done for executing this scenario.
Do I have need to do Data correlation, if yes? how to do this?
Do I need to add HTTP cookie manager or HTTP cache manager......
Please help guys, would be grateful :)
Naresh
Yes you must add the HTTP Cookie manager and HTTP cache manager

Resources