我使用的是 firefox12
并下载了 firebug-1.9.0.xpi
和 netExport-0.5.xpi
,但 har 文件不是创建的。可以进行任何更改。程序代码:
class Program
{
public IWebDriver webDriver;
public InternetExplorerDriver IEDriver;
static void Main(string[] args)
{
{
FirefoxProfile profile = new FirefoxProfile();
IWebDriver webDriver = new FirefoxDriver();
try
{
profile.AddExtension(@"D:\LoadTesting\firebug-1.9.0.xpi");
profile.AddExtension(@"D:\LoadTesting\netExport-0.5.xpi");
}
catch (IOException err)
{
}
profile.SetPreference("app.update.enabled", false);
String domain = "extensions.firebug.";
string output_dir =
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
output_dir = Path.Combine(output_dir, "Firebugnetexports");
if (!Directory.Exists(output_dir))
{
Directory.CreateDirectory(output_dir);
}
profile.SetPreference(domain + "currentVersion", "1.8.2");
profile.SetPreference(domain + "allPagesActivation", "on");
profile.SetPreference(domain + "defaultPanelName", "net");
profile.SetPreference(domain + "net.enableSites", true);
profile.SetPreference(domain + "netexport.alwaysEnableAutoExport", true);
profile.SetPreference(domain + "netexport.showPreview", false);
profile.SetPreference(domain + "netexport.defaultLogDir", output_dir);
try
{
webDriver.Navigate().GoToUrl("http://www.janodvarko.cz");
}
catch (Exception ex)
{
}
webDriver.Quit();
}
}
}
最佳答案
你最好的选择可能是使用 Browsermob proxy与 Selenium 结合。它将允许您在没有插件的情况下运行 Firefox,并输出 har 文件。该项目有 Selenium 的创建者和其他一些知名人物。 Github Project有一个示例,展示了如何创建 Har 文件,您可以从那里编写自己的代码来处理它并确保满足您的性能指标,或者找到您包含的 javascript/css,将其写入光盘等...
关于c# - 使用 Firebug 和 Selenium 自动进行页面加载性能测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11718420/