Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use jmeter with ajax request

How to use JMeter with ajax request?

I have a button with is clicked and by using fiddler I can find the session id which is being sent to the server.

What should I do next using the JMeter in order to handle this.

EDIT:

Let's say I have in my hand the header which call the request. The JSESSIONID AJAXREQUEST and so on where should I put it ?... I putted it in http header manager name and value.

like image 726
yoav.str Avatar asked Aug 09 '11 14:08

yoav.str


People also ask

How to handle AJAX request in JMeter?

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 .

How do I create a HTTP request in JMeter?

Create a Test Plan First For JMeter Post Requests Just right click on Test Plan and then click on the element by following this path: Threads (Users) -> Thread Group. Your Thread Group should be added now. And you can keep values in Thread Properties as they are.

Why use AJAX?

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page. Classic web pages, (which do not use AJAX) must reload the entire page if the content should change.

How do I record with JMeter?

In JMeter, by adding a Non-Test element to your test plan, enables you to capture the network traffic. Right click on Test Plan > Add > Non-Test Elements > HTTP(S) Test Script Recorder. This will add the recording capability to JMeter. To begin recording, understand the business flow and have your input data ready.


1 Answers

Jmeter will not execute Javascript embedded in your web page. However AJAX request is also a HTTP request that Jmeter will be able to run as a separate HTTP request and upon getting the response you can have post processors (using XPATH or REGEX) to extract the session id in a Jmeter variable.

Alternatively you can record the Jmeter scripts using Jmeter proxy and then all the HTTP requests will be recorded for you and you will just need to attach a post processor manually.

like image 104
anubhava Avatar answered Oct 01 '22 20:10

anubhava