gpt4 book ai didi

c# - .NET 库运行 web 性能测试

转载 作者:太空狗 更新时间:2023-10-29 19:39:45 26 4
gpt4 key购买 nike

我已经使用 Selenium Webdriver 在 C# 上编写了测试。现在我需要测试应用程序的性能。我使用了 FiddlerCore,但它没有页面渲染时间或动态内容(ajax、js 等)的时间。

有人知道像 FiddlerCore 这样的库,但有更多功能,如 dynatrace Ajax 版本或 C# 的 browsermob-proxy 吗?

编辑 1: 我不需要任何解决方案。我只想使用 WebDriver 进行测试。

最佳答案

我已经使用 BrowserMob 创建了性能测试,如下所示
- 下载最新的 BrowserMob:http://bmp.lightbody.net/
- 从 https://github.com/AutomatedTester/AutomatedTester.BrowserMob 获取 AutomatedTestter.BrowserMob
- 获取 Selenium
- 运行以下代码:

 // Supply the path to the Browsermob Proxy batch file
Server server =
new Server(
@"path\to\browsermob-proxy.bat");
server.Start();

Client client = server.CreateProxy();
client.RemapHost("host", "ip address");
client.NewHar("google");

var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
var profile = new FirefoxProfile();
profile.SetProxyPreferences(seleniumProxy);
// Navigate to the page to retrieve performance stats for
var driver = new FirefoxDriver(profile);
driver.Navigate().GoToUrl("http://google.com.vn");


// Get the performance stats
HarResult harData = client.GetHar();

AutomatedTester.BrowserMob.HAR.Log log = harData.Log;
AutomatedTester.BrowserMob.HAR.Entry[] entries = log.Entries;
foreach (var entry in entries)
{
AutomatedTester.BrowserMob.HAR.Request request = entry.Request;
var url = request.Url;
var time = entry.Time;
Console.WriteLine("Url: " + url + " - Time: " + time);
}



driver.Quit();
client.Close();
server.Stop();

关于c# - .NET 库运行 web 性能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9055549/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com