How to check request failure in a coded web test?

 
request5.Body = request5Body;
if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
{
 ValidationRuleFindText validationRule6 = new ValidationRuleFindText();
 validationRule6.FindText = "Meeting Details";
 validationRule6.IgnoreCase = false;
 validationRule6.UseRegularExpression = false;
 validationRule6.PassIfTextFound = true;
 request5.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule6.Validate);
}
yield return request5;
if (request5.Outcome == Outcome.Fail)
{
 StreamWriter sw = new StreamWriter("C:\\result.txt", true, Encoding.ASCII);
 sw.WriteLine("Meeting Creation Failed for the time zone " + this.Context["DataSource1.timeZone#csv.TimeZone"].ToString());
 sw.Close();
}
if (request5.Outcome == Outcome.Pass)
{
 StreamWriter sw = new StreamWriter("C:\\result.txt", true, Encoding.ASCII);
 sw.WriteLine("Meeting Creation Passed for the time zone " + this.Context["DataSource1.timeZone#csv.TimeZone"].ToString());
 sw.Close();
}
request5 = null;
this.MoveDataTableCursor("DataSource1", "timeZone#csv");
Advertisements
This entry was posted in Information Technology. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s