JMeter - ajax page - jmeter

I have a web page that calls another page via ajax during a page load. How can I replicate these two calls per user?
I have read various online resources around testing ajax based pages with JMeter but I'm still not clear on how to go about this.
So currently I have the following.
Thread Group:
- HTTP Request (Main page)
- HTTP Request (ajax call)
- Aggregate graph
Is this the correct approach? My assumption is each user will call the two HTTP requests, what I'm unclear about is how I can get the overall page load time for both requests.

If there is only one AJAX call - your approach is correct, you might want to put both the requests under Transaction Controller to see the cumulative time for the page load.
In case of more than one AJAX calls sequential approach won't be realistic as AJAX requests are being executed in parallel and currently JMeter doesn't provide relevant test elements to mimic this so you will need to do some scripting in order to properly simulate the AJAX calls. Check out How to Load Test AJAX/XHR Enabled Sites With JMeter article to get an idea on how this could be done and some examples.

Related

504 Gateway timeout in Jmeter

During manual run on reaching the Home screen, the page keeps loading and the API calls timeout with 504 error(Received the same error during Jmeter execution)
But if the same page(Home screen) is refreshed three times manually, all the previously timed out APIs load successfully (status:200).
But I'm unable to identify how to refresh the page using Jmeter. Any help on this? Thanks!
I tried adding JSR223 preprocessor with the following Javascript -
load("API-url") in the script section but it doesn't seems to work.
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 in order to "refresh" the page you need to send the same HTTP Request to it using HTTP Request Sampler. If you want to send the same request more than once it makes sense to put in under the Loop Controller
Also given the above quote from JMeter documentation if loading the page triggers some AJAX requests to the API - JMeter won't execute these requests automatically, you will need to create a separate HTTP Request sampler per API request. Also real browsers execute AJAX requests in parallel so if there is more than 1 API request - you need to put them under the Parallel Controller

Jmeter give error "We are sorry but vue-dms-ui-component doesn't work properly witouth Javascript enabled.Please enable it to continue"

In Jmeter, I have used "Recording with Think Time" for an application. Now when i run, in the Response I get message "We are sorry but vue-dms-ui-component doesn't work properly witouth Javascript enabled.Please enable it to continue".
I get this message for all the requests. I have enabled JavaScript in Firefox and then captured the recording.
Attaching the screenshot of the message.
enter image description here
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 it's not possible to "enable" JavaScript in JMeter.
If JavaScript is being executed on client-side only you can simply ignore this
If JavaScript generates a single network request - you need to mimic it using HTTP Request sampler
If JavaScript generates more than 1 network request at a time - use as many HTTP Request samplers as there are AJAX requests and put them under the Parallel Controller
Don't forget to perform correlation of dynamic parameters as in the vast majority of cases you cannot just replay the recorded network traffic.

Can JMeter record capture requests from a .razor page?

Currently on launching the login page of the application (which is a .razor page) through JMeter after providing all the necessary JMeter configurations, the contents of the page are not displayed in UI.
If the source of the request is .razor and JMeter by itself is not capable of recording it, how can such applications be recorded through JMeter? Is there any work around?
As per Wikipedia ASP.NET Razor article
Razor is an ASP.NET programming syntax used to create dynamic web pages with the C# or VB.NET programming languages.
JMeter doesn't know anything about the backend languages/technologies/patterns/whatever, it just sends HTTP requests, waits for responses and measures time in-between
In case of HTTP and HTTPS protocols you can record the requests using HTTP(S) Test Script Recorder
Looking at Introduction to Razor Pages in ASP.NET Core article it doesn't do any magic so JMeter should capture the requests and be capable of replaying them.
Just pay attention to these "async" calls, real browsers execute AJAX requests in parallel so if this is your case - you might want to put HTTP Request samplers representing async calls under the Parallel Controller
If JMeter is not recording anything the reasons could be in:
JMeter configuration is not correct: check jmeter.log file and your browser console window
The protocol(s) in use are not only HTTP/HTTPS, if there is something like WebSocket under the hood - you won't be able to record it with JMeter, you will have to inspect the requests using your browser developer tools and look for a way of replicating them using suitable JMeter Plugins

Performance test on a webpage which loads data from multiple API's

We have a webpage which will load data from multiple api's as configured by the users. While doing performance test of this page, In HTTP request I have added this page URL and executed the script. To my surprise, the script executed successfully with status as 200 as I dig into more I changed the drop down(In View Results Tree) from Text to HTML(Download Resources) and I don't see any page data in the response. Can someone help me with this. I'm not sure how to proceed with performance testing on this particular page.
As per JMeter project main page:
JMeter is not a browser
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).
My expectation is that your "multiple APIs" are triggered by JavaScript calls using AJAX technology. Given JMeter doesn't evaluate JavaScript it doesn't execute the AJAX requests which are being called by the real browser therefore you don't see the data coming from the APIs.
In order to get the browser-like behaviour you need to send the same requests which real browser sends, you can record them from the real browser using HTTP(S) Test Script Recorder or JMeter Chrome Extension
Also be aware that real browsers execute AJAX requests in parallel, in order to properly simulate browser's network footprint you need to place the HTTP Request samplers representing these API requests under the Parallel Controller

Much difference in time by single user without tool and single user with jmeter

I am trying to login to an application first with single user and recorded the time using "Page load time" plugin of chrome and then i am trying to login with Jmeter and applying load of Just 1 user but there is much difference in time.
is my approach correct? if yes why there is difference in load time.
Well-behaved JMeter request should give the same timings as browser does.
Make sure you configure your HTTP Request sampler to "Retrieve All Embedded Resources"
Ensure that you have Parallel downloads ticked
Add HTTP Header Manager and configure it to send all the HTTP Headers which browser is sending.
If web application you're trying to load test is built using AJAX technology you will need to add the relevant HTTP Request samplers to mimic asynchronous JavaScript-driven calls as JMeter doesn't execute client-side JavaScript. Once done you can combine requests into one "Login" sequence using Transaction Controller.
See How to make JMeter behave more like a real browser article for more hints on how to properly configure JMeter for web applications testing.

Resources