如何使用代码中的自定义firefox配置文件运行Selenium grid 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;
我唯一要做的就是强制Selenium网格使用我的自定义配置文件。
答案 0 :(得分: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;