2012-07-30 28 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被定位,寫入光盤等。 ..