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

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.

主站蜘蛛池模板: 聂荣县| 平顺县| 峨眉山市| 西青区| 宁河县| 垫江县| 大冶市| 通河县| 广宗县| 贞丰县| 探索| 泾川县| 福州市| 万全县| 甘泉县| 瓦房店市| 萨迦县| 桐柏县| 南投市| 桓台县| 萨嘎县| 天气| 清流县| 敦煌市| 抚松县| 昌江| 高密市| 千阳县| 诸暨市| 玉山县| 丰都县| 四会市| 江口县| 清水河县| 信宜市| 罗江县| 丹巴县| 卓资县| 青阳县| 无为县| 昌乐县|