1

我正在使用 Web 性能测试记录器进行负载测试。我的客户要求保存在 IE 上显示的 PDF 文件。是否可以仅通过 Web 性能测试来完成?如果没有,是否有任何可能的解决方案?

4

1 回答 1

2

据我所知,没有内置的方法来保存响应。您必须编写 WebTestRequestPlugin 才能将响应写入文件。

这是一个幼稚的实现作为起点。

public class SaveResponsePlugin : WebTestRequestPlugin
{
    [DisplayName("File Name")]
    [Description("Name of file in which to save the response")]
    public string FileName { get; set; }

    public override void PostRequest(object sender, PostRequestEventArgs e)
    {
        if (e.ResponseExists && !e.Response.IsBodyEmpty)
            File.WriteAllBytes(this.FileName, e.Response.BodyBytes);
    }
}
于 2014-02-26T22:33:43.027 回答