Page load time in jmeter - jmeter

How to get the page load time of an application which has n number of CSS, js, images, etc? How to do the configuration in JMeter?I have tried integrating selenium, but I can only find the scenario load time not the exact load time of a page.

There is a special setting responsible for parsing the DOM and retrieval of so called "embedded resources": images, CSS, JavaScript, sounds, fonts, etc.
It lives under "Advanced" tab of the HTTP Request sampler
If you have more than one HTTP Request sampler - consider adding HTTP Request Defaults configuration element, if you define the setting there - it will be applied to all HTTP Request samplers in the HTTP Request Defaults scope.

You can use Dmitri T's solution, but I think that solution is to simulate new users every time. You need to treat Jmeter as a protocol tool rather than a smart fully featured browser. I suggest you do scripts recording and put parallel controller in place and put recorded scripts under the parallel controller.
You need to make sure you understand each time a page is loading, which ones are cache, which ones are not. Using recording scripts to add them under parallel controller, I think you can download the parallel controller in Jmeter plugin manager..

Related

Retrieve all Embedded resources is not working in JMeter

I am using "Retrieve all Embedded resources" advanced option to retrieve all static content.
It work fine but does not retrieve below .js. Is there any Filter or option in JMeter to get below files ?
I don't see any "below .js", just in case be aware of the following limitation:
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).
so if an "embedded resource" is being triggered by the client-side JavaScript - JMeter won't be able to process the JavaScript hence won't download the associated piece of content. If this is your case - you will need to download it using a separate HTTP Request sampler and put both "main" HTTP Request and the second one under the Transaction Controller to get the cumulative time. If there are multiple occurrences of such assets - put them under a Parallel Controller

AJAX Defaults Config

Can someone please give me an explanation of AJAX Defaults Config or what is the role of it in Jmeter?
I tried to search for an answer in Google but I can't find a definite definition of it.
As of JMeter 5.1.1 there is no such a thing as AJAX Defaults Config in JMeter Components so most probably you're using some form of JMeter Plugin which is not publicly available. If this is the case you should reach out to the plugin developers/maintainers for the clarification.
For the vanilla JMeter, 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).
Therefore JMeter is not capable of automatically execute AJAX requests because J letter stands for JavaScript
If you need to properly simulate AJAX requests you need to add a separate HTTP Request sampler per AJAX call and put them under Parallel Controller to ensure

How to find exact response time in jmeter?

How to find the exact time taken for my web page to load using jmeter? Since i am getting 3 sec as response time but manually it takes more than that to load the page.
Most likely you didn't check Retrieve All Embedded Resources box in the HTTP Request sampler (or even better HTTP Request Defaults) so your request basically gets only HTTP response but doesn't resolve any nested content (images, styles, scripts, fonts) which have much more "weight"
See Web Testing with JMeter: How To Properly Handle Embedded Resources in HTML Responses article to learn more about how to work with these "embedded resources"
Another inconsistency can be caused by JMeter not executing AJAX requests, i.e. if your application relies on JavaScript-generated requests and rendering their responses. JMeter is not a browser and it doesn't automatically execute JavaScript found in the HTML response so if this is the case you will need to manually add these requests to your Test Plan (or record them using HTTP(S) Test Script Recorder) and measure cumulative time via i.e. Transaction Controller.
As a follow on to Dmitri's post, take the page in question and examine it using the developer tools of your chosen browser. Examine very specifically the split between client side actions (JavaScript, Rendering, Painting, ...) and server side requests. In all likelihood you are timing A with Jmeter and B with your eyes

In j meter test script why we exclude java script,cascade style sheet and include only html to check response time in performance test?

While checking performance of public website why we exclude java scripts, style sheets and include only basic request which returns HTML file(host "www.test.com" and "/" in path.
You need to exclude these scripts, styles and images only during recording of your test scenario with the HTTP(S) Test Script Recorder as if you record these calls they will be captured, but when you replay them it will have nothing in common with that happens in the reality.
Real browsers act as follows:
They download these scripts, images and styles when requesting the main page, but do it in parallel using several concurrent threads to speed up the process. So the main request forks into several sub-requests which are downloading all this stuff. In JMeter you can mimic this behaviour using "Retrieve All Embedded Resources" switch either in HTTP Request or in HTTP Request Defaults
As you already know, browsers download scripts, images and styles and do it using several concurrent threads. The next point is that well-behaved browsers do it only once, on subsequent requests this stuff is being returned from the browser's cache. So you need to add a HTTP Cache Manager to your Test Plan to simulate this functionality representing browser cache and not overload the server
Regarding 3-rd party content. If your web site uses scripts, images, videos, etc. from other domains - it is recommended to exclude these requests from your load testing scope as most likely you don't have any control of these 3-rd party content providers and won't be able to do anything even if the bottleneck is due to external server, your load test should focus solely on your application.
See How To Make JMeter Behave More Like A Real Browser guide for more information on above hints and few more recommendations.
Because JMeter is only retrieving page elements, and does not execute javascript or render these components like real browsers do. Personally i like to retrieve all embedded resources to give myself a better understanding of the total load time, even if javascript is not executed/rendered.
You can also do a selective retrieval, or a full retrieval if you wish.
Use the checkbox named "retrieve embedded resources", or specify which elements should be retrieved. Getting full retrieval is also handy to see whether there are broken links to components in the page.

Why do we exclude jpg,css file in jmeter script

I am just wondering why do we exclude photos and css files in jmeter script because if i think from end user prospective,images takes more time to load.
The only content to be excluded from test script is "external" content, i.e. any third-party banners, pictures, maps, analytics, etc. content needs to be filtered out.
JMeter test needs to be as much realistic as possible to correctly simulate user activity. So:
Images, scripts, styles, etc. do not need to be excluded from JMeter test
The best way to handle them is as Vinoth S suggests using "Retrieve All Embedded Resources" functionality (and it is also better to use concurrent pool of 2-4 threads for it). The most optimal way of configuring it is via HTTP Request Defaults config element so the change could be applied to all HTTP Request Samplers.
It is also good to add HTTP Cache Manager from "reality" perspective as real browsers download all this stuff like images, scripts and styles, but they do it only once, on subsequent requests the content is being returned from browser's cache and the actual request to the server is not being made.
See How to make JMeter behave more like a real browser guide for other recommendations on how to make your test more realistic.
css/jpg/js files are all embedded static resources in the HTML response you get.
so instead of sending a recorded request, you can select the below option in the HTTP sampler. JMeter will take care of downloading these files for you just like a real browser.

Resources