access the response from a web coded performance test

风格不统一 提交于 2019-12-21 02:26:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!