官术网_书友最值得收藏!

Testing AJAX-centric applications

In today's stack of web applications, it is almost unthinkable to build an application without some dynamic content being retrieved from a backend service. Most of the time, these applications tend to lean towards partial page fresh. That is, only the needed sections of a rendered page are refreshed as opposed to the whole page loading its entire content again. This leads to more responsive pages, which improves the overall experience of the user.

How to do it…

In this recipe, we will walk through how you can test such applications using JMeter. Perform the following steps:

  1. Launch JMeter.
  2. Add HTTP(S) Test Script Recorder and set it up for recording (see the Recording a script via JMeter HTTP proxy recipe).
  3. Click the Add suggested Excludes button.
  4. Start the HTTP(S) Test Script Recorder.
  5. Point your browser to https://maps.google.com.
  6. Perform a couple of searches in the provided search box (for example, pizza, restaurants, hotels, and so on).
  7. Click on a few of the returned results.
  8. Repeat steps 6 and 7 two more times.
  9. Stop the HTTP(S) Test Script Recorder.
  10. Add a listener to your test plan.
  11. Save and run the test plan.

How it works…

The actions of the user are tracked and recorded via the script recorder we set up in step 2. Like traditional web applications, we record all actions and exclude irrelevant static resources, such as images, JavaScript, and style sheets. Calls that trigger backend server calls are trapped and are available for replay later. At the end, we have a script that is almost identical to what we would get when recording a traditional web application.

There's more...

AJAX-centric applications tend to involve a lot of asynchronous server requests made from within the client (frontend). These calls are normally made from embedded script tags within a view technology, for example, HTML, Java Server Pages (JSP), Groovy Server Pages (GSP), or from an included JavaScript file in the page. As such, JMeter records all such server requests and they can be played back at the time of running our test plans. This allows us to simulate the intended load on our servers, as though the application was the one making the AJAX calls.

主站蜘蛛池模板: 滕州市| 大厂| 新郑市| 罗江县| 阳曲县| 绥江县| 广州市| 星子县| 乌鲁木齐县| 鸡西市| 华坪县| 惠安县| 清水河县| 贵德县| 齐河县| 弋阳县| 高要市| 青冈县| 巴塘县| 马龙县| 台州市| 山阴县| 高州市| 肃南| 招远市| 洪洞县| 霍林郭勒市| 马公市| 察隅县| 容城县| 鄂尔多斯市| 溧水县| 昌宁县| 长顺县| 安塞县| 永济市| 杭锦后旗| 宁武县| 秦皇岛市| 墨玉县| 宽甸|