I managed to Get an Ajax web page working using Fiddler
Below is an exmaple of how to get an ajax web app to record a web test.
I used fiddler to record the button click events and then opened the fiddler webtest file in notepad and then created a coded test within team system. I have spent a couple of days tinkering with this.
If anyone needs some help with this let me know.
//Go to the Default page
request1.ThinkTime = 7;
request1.Method ="POST";//Click the New ticket Button
FormPostHttpBody request1Body =newFormPostHttpBody();
request1Body.FormPostParameters.Add("Anthem_UpdatePage","true");
request1Body.FormPostParameters.Add("__EVENTTARGET","ctl0TicketContentArea$DealingControl$btnNewTicket");
request1Body.FormPostParameters.Add(
"__EVENTARGUMENT","");ExtractHiddenFields rule1 =newExtractHiddenFields();
rule1.ContextParameterName ="1";
request1.ExtractValues +=newEventHandler<ExtractionEventArgs>(rule1.Extract);
request1.Body = request1Body;yieldreturn request1;WebTestRequest request2 =newWebTestRequest(http://localhost/Default.aspx);
request2.ThinkTime = 7;
request2.Method ="POST";//Fire the Next Button
FormPostHttpBody request2Body =newFormPostHttpBody();
request2Body.FormPostParameters.Add("Anthem_UpdatePage","true");
request2Body.FormPostParameters.Add(
"__VIEWSTATE",this.Context["$HIDDEN1.__VIEWSTATE"].ToString());request2Body.FormPostParameters.Add(
"__EVENTTARGET","ctl00$TicketContentArea$DealingControl$DealTicket$Buttons$NextButton");request2Body.FormPostParameters.Add(
"__EVENTARGUMENT","");ExtractHiddenFields rule2 =newExtractHiddenFields();rule2.ContextParameterName ="1";
request2.ExtractValues +=newEventHandler<ExtractionEventArgs>(rule2.Extract);//Check if any validation has fired//Check Stock Validationif ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
{
rule3.FindText ="please supply a stock";
rule3.IgnoreCase =true;
rule3.UseRegularExpression =false;
rule3.PassIfTextFound =true;
request2.ValidateResponse +=newEventHandler<ValidationEventArgs>(rule3.Validate);
}request2.Body = request2Body;yieldreturn request2;

