2013-05-02 53 views
0

如何使用代碼中的定製的Firefox配置文件運行Selenium網格2。使用定製的Firefox配置文件運行硒網格2

這是我現在有代碼:

DesiredCapabilities capabilities = DesiredCapabilities.Firefox(); 

      capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true); 
      capabilities.SetCapability(CapabilityType.HasNativeEvents, false); 
      capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); 
      capabilities.IsJavaScriptEnabled = true;    
      Uri url = new Uri("http://localhost:4444/wd/hub"); 
      RemoteWebDriver driver = new RemoteWebDriver(url, capabilities); 
      return driver; 

我留下的唯一一件事就是迫使硒電網使用我的自定義配置文件。

回答

1

找到解決方案:

var firefoxProfile = new FirefoxProfile(); 
// configure firefoxProfile ... 
DesiredCapabilities capabilities = DesiredCapabilities.Firefox(); 

      capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true); 
      capabilities.SetCapability(CapabilityType.HasNativeEvents, false); 
      capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows)); 
      capabilities.IsJavaScriptEnabled = true;     
      capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, firefoxProfile.ToBase64String()); 
      Uri url = new Uri("http://localhost:4444/wd/hub"); 
      RemoteWebDriver driver = new RemoteWebDriver(url, capabilities); 
      return driver; 
+0

我已經有了這個解決方案只是我不知道我不得不打電話ToBase64String上的配置文件。這在哪裏記錄? – 2015-08-24 21:48:39

相關問題