2012-07-30 53 views
2

我正在使用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(); 

     } 

    } 
} 

回答

2

你最好打赌可能是使用Browsermob proxy与硒联合使用。它将允许你运行Firefox而无需插件,并输出har文件。该项目拥有Selenium的创造者,以及其他一些知名人物。 Github Project有一个示例,显示如何创建Har文件,从那里你可以编写你自己的代码来处理它,并确保你的性能指标得到满足,或者你包含的javascript/css被定位,写入光盘等。 ..