Tracing AJAX requests

You can test AJAX-based applications in two different ways; by setting the Auto Trace option to true or by setting the Auto Trace option to false on the corresponding document object. By setting Auto Trace option to true, you can trace the AJAX requests.
The following example shows how to use the getAjaxPendingRequests and waitForAjaxCompletedRequests. The getAjaxPendingRequeststo method is used to return the number of AJAX pending requests at any given point of time since the first AjaxTraceOn. The waitForAjaxCompletedRequestsTo method is used to wait for the specified number of AJAX requests to be completed. If the argument is not specified, it waits till the pending requests becomes zero.
Note: When the pending requests become zero, ensure that you turn off the Auto Trace option.
public class AjaxRequestExample extends AjaxRequestExampleHelper
	 * Script Name   : AjaxRequestExample
	 * Generated     : Apr 24, 2012 2:52:37 PM
	 * Description   : Functional Test Script
	 * Original Host : WinNT Version 5.1  Build 2600 (S)
	 * @since  2012/04/24
	 * @author Functional Test User
	public void testMain(Object[] args) 
	public void ajaxTraceTest() {
		 startBrowser("Internet Explorer",
		"<AJAX related Web Application URL>");

		// When is set to true, turn the AJAX Request tracing facility to 'On' at the HTML document level.

		// perform AJAX-related actions.
		text_xvalue().click(atPoint(72, 10));
		list_xfrom().click(atText("EUR - Euro"));

		 * ++++++++++Use one of the following three functions:
     a) waitForAjaxPendingRequests() - Wait for all the pending request to be served.
     b) waitForAjaxPendingRequests(5) - Wait for the 5 pending request to come 
     c) waitForAjaxCompletedRequests(3) - Wait for 3 completed AJAX requests
		 * Just to illustrate we have used a,b and c - in the real use case we expect you to use any one of the function.

		// Wait until all pending requests are completed.

		// Number of allowed pending requests, otherwise throw AjaxTimeOutException on timeout

		// Wait until the specified count of AJAX requests are completed. Otherwise throw AjaxWaitTimeOutException on timeout.

		// When is set to false, turn the AJAX Request tracing facility to off