下面是我的基本代码,用于试用Browsermob,以及生成的输出。问题在于输出,它似乎(1)在数量上不完整,(2)没有我会手动检查开发工具(Firefox或Chrome)中的网络统计数据那样详细。
有可能在HAR文件中获得更详细的信息吗?我想知道,例如,是否加载了特定的(或者是否有更好的解决方案?)
// Supply the path to the Browsermob Proxy batch file
Server server = new Server(@"C:\Users\Frederik\Desktop\SeleniumTestje\browsermob-proxy-2.1.0-beta-6\bin\browsermob-proxy.bat");
server.Start();
Client client = server.CreateProxy();
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
IWebDriver driver = new FirefoxDriver(profile);
driver.Navigate().GoToUrl("http://www.google.co.uk");
// Get the performance stats
HarResult harData = client.GetHar();
foreach(Entry e in harData.Log.Entries)
{
Console.WriteLine(e.Request.Url, e.Request.Headers);
}控制台中的输出:
http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://ocsp.digicert.com/
http://www.google.co.uk/
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp
http://clients1.google.com/ocsp发布于 2016-05-03 05:27:03
我和Fiddlercore也有同样的问题,但我找到了一个解决方案:Fiddlercore - Requested resource URL's are generic (OSCP-related) instead of actual resource
发布于 2019-07-01 20:42:35
我也遇到了这个问题。结果是Chrome的网络工具默认启用了自己的缓存,因此BrowserMobProxy并不知道所有的请求。
若要修复自动.har,使其与手动相同,请选择网络工具中的禁用缓存复选框。更多信息在这里:Disabling Chrome cache for website development
https://stackoverflow.com/questions/36848563
复制相似问题