How to execute Ajax requests in JMeter?

Mitra Alidoosti picture Mitra Alidoosti · Jan 2, 2017 · Viewed 11.5k times · Source

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

Answer

Naveen Kumar R B picture Naveen Kumar R B · Jan 2, 2017

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 by xhr, 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 using HTTP 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 the Test Plan without HTTP 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.