jmeter load test getting dynamic values from array variable - performance

I want handle the following url parameter dynamically in jmeter load testing
filters=%7B%22TIME_PERIOD_TYPE%22:%5B%22QTD%22%5D,%22COUNTRY%22:%5B%22%22%5D,%22TERRITORY%22:%5B%22PTPT_SL_FE_N_T01%22%5D,%22ACCOUNT_BRICK%22:%5B%22%22%5D,%22OVERALL_PRIORITY%22:%5B%22%22%5D,%22PRODUCT_PRIORITY_PRODUCT%22:%5B%22%22%5D,%22ACCOUNT_SPECIALTY%22:%5B%22%22%5D,%22ACCOUNT_TARGET_TYPE%22:%5B%22%22%5D,%22ACCOUNT_VISITABLE_TYPE%22:%5B%22%22%5D,%22ACCOUNT_SUB_TYPE%22:%5B%22%22%5D,%22HCO_SUB_TYPE%22:%5B%22%22%5D,%22ACCOUNT_MARKET_SEGMENT%22:%5B%22%22%5D%7D
Here are Jmeter sampler for filtering the value
How can I handle those values dynamically using corelation? Filter value can vary for menus

The options are in:
Correlate all the values one by one using the suitable Post-Processor
Get all input names/values from the previous response using i.e. CSS Selector Extractor and populate them in the next request using JSR223 PreProcessor and Groovy language.
Use a 3rd-party recording tool like BlazeMeter Proxy Recorder, it's capable of exporting recorded requests in "SmartJMX" mode with automatic detection and correlation of dynamic parameters, see How to Cut Your JMeter Scripting Time by 80% article for more details

Related

how do i capture multiple response from server and from that i have to check specific response by JSR223 sampler in jmeter?

USing WS plugin -- For single request ,server returns multiple responses in my application.
This is a gaming application. For game play request, it sends multiple response in return based on game logic.The value of attributes in response (EX: {"server":{"event":"broadcast","broadcastaction":"gamevents" --attribute broadcastaction changes)changes according to game flow. sometimes ,broadcastaction attribute is not there in response.
Multiple conditions to be checked in my response.
So i have to capture all response or i have to check whether the specific value is present in response using multiple if conditions in jsr223 (java) sampler.
Below is a example for response which changes as mentioned below based on game flow
Ex:
1.{"server":{"event":"***","tr":"0"}
2.{"server":{"csh":0.0,"id":"3","action":"$$$$","value":"normal######"}
3."server":{"csh":0.0,"id":"0","action":"******","score":"-*","count":"1"},{"csh":0.0,"id":"0","action":"###","value":"***"}]}}
4."server":{"csh":0.0,"id":"0","action":"******","score":"-*","count":"1"},{"csh":0.0,"id":"0","action":"###","value":"***"}]}}
I think you're looking for a JSR223 Assertion and Groovy language as:
Groovy has built-in JSON support
It has handy shorthands to JMeter API allowing access to response data and result manipulation so you can conditionally mark sampler as passed or failed
It's the most performing scripting option comparing to other available languages
More information: Scripting JMeter Assertions in Groovy - A Tutorial

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 save load time into a variable

I cannot seem to save the load/response/sample time into a variable using RegEx.
Sampler Results page
Is there a way to access the results from the Sampler Results page?
You cannot extract Response time using regular expressions because regular expression extractor is limited to the following options and response time is calculated by JMeter
However you can use JMeter's SampleResult api to get load time.
The api has methods for endtime and starttime of a sample, using this methods you can calculate load time and then store it in JMeter variable.
Loadtime= endtime-starttime
Add a Beanshell post processor to your sampler and add the following code to the post processor
long starttime=prev.getStartTime();
long endtime=prev.getEndTime();
int loadtime=endtime-starttime;
vars.put("Load time",Integer.toString(loadtime));
You can use ${Load time} to get load time of that particular sample
More info:
Regular expression extractors
Beanshell

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.

How to decide which value to fetch?

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.

Resources