I want to execute Ajax requests in JMeter. I record my test plan with JMeter and BlazeMeter but none can handle Ajax requests. How can I solve my problem?
Or is there any tool that can send concurrent Ajax requests?
Thanks in advance, M.A
I want to execute Ajax requests in JMeter. I record my test plan with JMeter and BlazeMeter but none can handle Ajax requests. How can I solve my problem?
Or is there any tool that can send concurrent Ajax requests?
Thanks in advance, M.A
you can do that by recording http traffic with JMeter Proxy
http://jmeter.apache.org/usermanual/jmeter_proxy_step_by_step.pdf
but it is only possible to replay the same traffic, can be problematic for sessions, cookies... Better solution is to use WebDriver
https://jmeter-plugins.org/wiki/WebDriverTutorial/
https://jmeter-plugins.org/wiki/PluginInstall/
the needed package is https://jmeter-plugins.org/files/packages/jpgc-webdriver-1.4.0.zip
It is not possible as kicking off more threads than originally defined in the Thread Group is not currently supported, the feature is being tracked as Bug 53159. AJAX requests are "normal" HTTP Requests so JMeter can record and replay them, but when it comes to asynchronous execution - you cannot do this as of now. The workaround options are in:
Learn more: How to Load Test AJAX/XHR Enabled Sites With JMeter
I had this same problem after recording samplers using the JMeter Proxy. The answer was on this blog post: https://lincolnloop.com/blog/load-testing-jmeter-part-1-getting-started/ - see the Ajax Requests section.
Add an HTTP Header Manager for the ajax request and make sure you are sending the X-Requested-With:XMLHttpRequest
header.
By default, Ajax requests can't be simulated by JMeter as it does not process
.js
files (As of 3.1 version). You have to explicitly add the requests (HTTP Samplers) for AJAX requests.Use
Network
tab of a browser (F12 option) and filter the traffic byxhr
, which shows only AJAX requests. Add those requests as HTTP Samplers in the script at the point you needed in the Test Plan.Browser can process
.js
files, hence AJAX requests are sent from the browser. When you record the script usingHTTP Test Script Recorder
, as you are using the browser to navigate, even AJAX requests (originated from js files) will also be added/recorded to the Test Plan.Since JMeter can't process
.js
files due to limitation, manually add the AJAX requests (nothing but HTTP Get or Post requests) using HTTP Sampler, if you are building theTest Plan
withoutHTTP Test Script Recorder
.Note: If you are using
HTTP Test Script Recorder
, no need to add them manually as they are already recorded in the Test Plan.