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
WebTestRequest request1 =newWebTestRequest(http://localhost/Default.aspx);
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 Validation

if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))

{
ValidationRuleFindText rule3 =newValidationRuleFindText();
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;

[6565 byte] By [GregorSuttie] at [2007-12-21]
# 1

I've got a 3rd party control in my app that uses Ajax but even using Fiddler to record the requests has not helped. Can you add some comments to your posted example to provide additional step through detail?

When I post a form I get a validation error that indicates no value is being posted from the Ajax based control.

Any suggestions would be welcome.

Thanks.

FlyingHigh at 2007-9-10 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...

Visual Studio Team System

Site Classified