Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute Ajax requests in JMeter?

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

like image 560
Mitra Alidoosti Avatar asked Jan 02 '17 08:01

Mitra Alidoosti


1 Answers

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.

like image 87
Naveen Kumar R B Avatar answered Oct 31 '22 22:10

Naveen Kumar R B