c# - 使用 Firebug 和 Selenium 自动进行页面加载性能测试

标签 c# selenium firebug webdriver

我使用的是 firefox12 并下载了 firebug-1.9.0.xpinetExport-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/

相关文章:

c# - 重写规则以重定向 URL

javascript - 在 C# 中将 JavaScript AST (Esprima.Net) 遍历到树

python - Selenium Page down by ActionChains

python - 如何使用 Selenium 处理和选择网站上日期选择器中的元素?

html - Firebug 修复相同的 css?

javascript - 是什么让 Firebug/Chrome 控制台将自定义对象视为数组?

c# - RadGrid 中的 ComboBox

c# - c# 两台电脑之间的通信

selenium - 组合 XPath 选择器来选择后代或自身

javascript - 在 Firebug 中,$ == jQuery 仅在某些时候返回 false