问题
WebTestRequest request1 = new WebTestRequest((this.Context["Environment"].ToString() + "/IBWeb/DefaultSB.aspx"));
request1.Headers.Add(new WebTestRequestHeader("Referer", (this.Context["Environment"].ToString() + "/IBWeb/")));
ExtractHiddenFields extractionRule1 = new ExtractHiddenFields();
extractionRule1.Required = true;
extractionRule1.HtmlDecode = true;
extractionRule1.ContextParameterName = "1";
request1.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
yield return request1;
request1 = null;
I have a coded web performance test as mentioned above.. The test runs without any issues..But I would like to access the output/response from the WebTestRequest
object. what is the best approach to do it ?
回答1:
add PostRequest event handler
request1.PostRequest += new EventHandler<PostRequestEventArgs>(request1_PostRequest);
handler method:
void request1_PostRequest(object sender, PostRequestEventArgs e)
{
String responseBody = e.Response.BodyString;
}
来源:https://stackoverflow.com/questions/18082377/access-the-response-from-a-web-coded-performance-test