When I record a script in Jmeter I get hundreds of samplers that I don't need.
How can I identify which samples can be deleted without impacting the script functionality?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityWhen I record a script in Jmeter I get hundreds of samplers that I don't need.
How can I identify which samples can be deleted without impacting the script functionality?
You need to refine your scripts for the unwanted requests as per below mentioned ways
When you use this Exclusion, most of your unwanted requests/samples will get reduced automatically and instead of hundreds of request you will see few requests.
If your application is communicating to other application/URL through some plugin or other way round, then you need to delete those requests from your recorded script. Just look at the URL which is being called from sampler detail, if that URL does not belong to your application (i.e. IP/domain name is different from yours) then delete such samplers e.g. call being placed to facebook, twitter, some live-chat support plugin.
You need to keep only those HTTP requests which are calling/hitting your application GET/POST method for either posting your request with some parameters and getting response from the server. Any request which is neither posting anything or not getting any response from the server should be deleted. For this too you need to verify samples from their detail.'
When using step 3, first try with 'Deactivating' the samples, if your script works after deactivating then delete those deactivated requested. This is just a backup plan, in case your script doesn't work after delete or you delete some required request by mistake then by using Deactivating method you can still get it back and make your script working. It is just to avoid some rework (else script need to be re-recorded), Once you get used to this process you can directly go with the delete sample step, instead of first making it inactive and then deleting them.
Exclude all the external domains which are not related to the web application you're testing. I.e. if it displays map from Bing - remove this sampler, if application plays video from Youtube - remove it as well as you ain't gonna need it. See Excluding Domains from the Load Test guide for details on how to filter out unwanted domains.
If you open File -> Templates -> Recording in JMeter and look at the HTTP(S) Test Script Recorder configuration, you'll see that some content types are being excluded from recording, e.g. bmp, css, js, gif, etc.
So if you replicate this configuration - requests to these images will be filtered out.
Actually it is not correct to completely remove these requests as real browsers:
So "good" configuration would be:
Configuring HTTP Request Samplers (better via HTTP Request Defaults) to
You can add unwanted URL patterns to exclude in HTTP Test Script Recorder. I have written about this concept here with examples.
https://learn-jmeter.blogspot.in/2016/10/how-to-record-script-in-apache-jmeter.html
The important thing is to use the Test Recorder fields URL Patterns to Include and URL Patterns to Exclude.
In Patterns to Include, use .*\.html
unless there are specific pages you need to exclude.
In Patterns to Exclude, use (?i).*\.(bmp|css|js|gif|ico|jpe?g|png|swf|woff)
to avoid recording style, image, font, and animation files.
The patterns are Regular Expressions, so you can improve your filtering by learning more about regular expressions and how they work