How to decide which value to fetch? - jmeter

I have jmeter script contains five transactions of which one transaction contains more than one dynamic values. And I want to know how to decide which value to fetch in order to pass it to further transaction?

You need to fetch those values which are required.
Record your scenario 2 times
Inspect request details using View Results Tree listener
Find request parameters (they may be in the request headers as well) which are different between 2 recordings
These are the dynamic parameters you need to correlate (extract from the previous response and pass to the next request)
Alternatively you can use a cloud-based JMeter scripts recording solution which is capable of exporting recorded scripts in "SmartJMX" mode with automatic correlation of all dynamic parameters so you won't have to worry about it. Check out How to Cut Your JMeter Scripting Time by 80% guide for details.

Related

I am not able to record place order activity and perform load testing on randomly generated URL

at the time of recording activity I am recording complete activity till place order, but when run the same action for 5 times, in result everytime its hitting same URL that has been generated while recording, but because of it place order not recording to my admin account.
In the majority of cases unfortunately you will not be able to successfully replay the recorded script because modern web applications widely use dynamic parameters for various reasons like client side state tracking or security reasons.
So you need to parameterize and/or correlate your test and replace recorded hard-coded values with either dynamic parameters which needs to be extracted from the previous response using a suitable JMeter Post-Processor or provide random values or use pre-defined values from i.e. external CSV file.
The easiest way of detecting dynamic parameters is recording your test one more time and comparing 2 recorded script - the parameters which will differ will require your attention.
You can also consider using an alternative recording solution which is capable of exporting recorded scripts in "SmartJMX" mode with automatic detection and correlation of the dynamic values, check out How to Cut Your JMeter Scripting Time by 80% article for more details.

How to test two HTTP requests in Jmeter without affecting the performance of individual requests and how to only record the results of one?

I'm doing a performance test of a HTTP Patch Method Request using Jmeter called 'Update Person'. The case here is the Update Person is dependent on another request called 'Create Person'. Create Person will return a 'personId' as a response and I will use that id to send an update request. So I can't do a performance test with only the Update Person Request. Here is my Jmeter Test Plan Layout:
Jmeter Test Plan
When I run the test plan, the performance of both request is significantly slower than testing the Create Person alone. My questions are:
Does testing two http requests affects the performance? If yes, how?
Is there a way that I can test my Update Person request alone while the Create Person request is running in the background to get the personIds?
Thank you.
1.You can first run the create person alone and get all the required person ids in the csv. For this you can use the post processors and capture and write the output or take it directly from DB if it is there and you can.
2. Then, pass the created ids to the second request from the csv using CSV Data Set config.
Update:-
Use regex or any post processor for fetching the UserId then with in the same sampler use BeanShell PostProcessor to write the output to csv:-
Ex:-
CreatePerson = vars.get("Create_Person");
f = new FileOutputStream("C:/Users/XXX/Users.csv", true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(CreatePerson);
f.close();
This can also be achieved with Groovy for performance improvement. I am not an expert on Groovy but you can find that on this site. Dmitri T has submit that many times.
Then, for reading it is very easy. Add "CSV Data Set Config" before the samplers or on top to fetch the data. Column name need to be passed as variable where it is required like ${CreatePerson}
There is one more thing to capture the data instead of code. Use Sample Variable. In the user.properties(under bin folder) file add a line in the end:-sample_variables=CreatePerson
Then, use simple data writer or view result listener to save the results in the csv. It should write the data in the csv. You can deselect all the data that is not required from the simple data writer/view result listener.

How do I record a script in JMeter which adds a record in a website?

Currently, I am recording a script in jmeter by which I am adding a record in a website , but a problem is that while recording a script I am able to add a record in a website, but once recording has been done and after that if I will run a script again then, a script is not adding a record in a website.
can you please help me with this?
In the absolute majority of cases you will not be able to replay the recorded script without performing correlation.
Modern web applications widely use dynamic parameters for session management or CSRF protection so once you record your test you get "hardcoded" values and they need to be dynamic.
Assuming all above my expectation is that your test doesn't add record due to failed login or something like that. Inspect requests and responses using View Results Tree listener - this will allow you to identify which exact step is failing.
The process of implementing the correlation looks as follows:
Identify the element which looks to be dynamic either manually inspecting request parameters and look for "suspicious" patterns or record your test one more time and compare the recorded scripts looking for the parameters which differ
Inspect previous response and extract the dynamic value using a suitable post-processor. For HTML response times the best option is CSS Selector Extractor. It will allow you to extract the dynamic parameter value and store in into a JMeter Variable
Replace hardcoded recorded value with the variable from the step 2
Repeat for all dynamic parameters
Don't forget to add HTTP Cookie Manager to your Test Plan.

Jmeter hml request order get change when increase the number of users and due to that post reguler expression get failed

I record and run the Jmeter script by keeping number of users = 1, in tread group.
Results tree output:
I increased the number of users to 3 and result tree output order changed.
Therefore my some of regular expression exacter logics get failed and resultant responses failed. How can I avoid this situation.
Is there way to manage result tree execution order.
If your regular expressions are under the requests and not at the same level as of HTTP requests then it should not be a problem.Every thread/vUser will run independently. But, in view results you will see request as and when executed by different threads and not in sequence.
As per JMeter Functions and Variables user manual chapter:
Variables are local to a thread
Each JMeter thread (virtual user) executes Samplers upside down (or according to the Logic Controllers). JMeter threads are absolutely independent from each other and each thread has its own variables.
So the problem must be somewhere else, inspect the state of the variables using Debug Sampler and the response data for /oauth calls - it might simply not contain the necessary token value.
Also there is a suspicious call to bundle.js, my expectation is that you should not be executing it directly. The good practices is to configure HTTP Request Defaults to download embedded resources and use parallel pool to be closer to what real browsers do.
See Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses article for more detailed explanation.

Jmeter record and play scripts for performance testing

I want to do a performance test of a website so i am creating a script that mimics user behaviour. I am using blazemeter to record those scripts and upload it in jmeter. I have two questions:
1) Do the results of a record and play script vary when run on another machine or a different time ?
2) I am getting a 400 bad request error in one of the steps of the recorded script.
What should i do ?
Is there any other way to test the web pages other than record and play ?
The chance of getting a good load test from recording is minimal as modern web applications widely use dynamic HTTP Cookies HTTP Request Parameters for different reasons (security, tracking client state, etc)
So after recording your test scenario "skeleton" most likely you will need to perform so called correlation - the process of
detecting dynamic parameters
extracting them using JMeter Post Processors and storing into JMeter Variables
and reusing the variables where required
Detecting parameters is quite simple: just record your test 2 times and compare request defaults: if you see differences - you will need to perform the correlation.
Extracting dynamic parameters is a bigger story, choosing the right extractor depends on response type, for example:
for HTML response types use CSS/JQuery Extractor
for XML/XHTML and in some cases HTML use XPath Extractor
for JSON - JSON Extractor
for anything else - Regular Expression Extractor which works with any text (including all above response types)
Also be aware that there is a solution allowing to perform JMeter correlation in an automated manner so you won't to detect and handle the dynamic parameter manually, check out How to Cut Your JMeter Scripting Time by 80% article for more details.

Resources