【发布时间】:2017-02-14 22:18:16
【问题描述】:
我目前正在使用适用于 Firefox 的新 Marionette 驱动程序更新我的 C# 解决方案。
我已经设法让驱动程序使用以下代码成功启动一个 url
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Directory.GetCurrentDirectory(),"wires-0.6.0-win.exe");
service.FirefoxBinaryPath = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
FirefoxDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("http://www.google.com");
但是我需要在初始化时向驱动程序添加配置文件才能设置代理。我以前是这样做的(对于较旧的 Firefox 版本)。
private static IWebDriver InitialiseFirefoxDriver(Proxy proxy)
{
FirefoxProfile profile = new FirefoxProfile();
if (proxy != null)
{
profile.SetProxyPreferences(proxy);
}
return new FirefoxDriver(profile);
}
不幸的是,FirefoxDriver 构造函数只允许我传入 FirefoxDriverService 或 FirefoxProfile。有谁知道我可以设法在创建驱动程序之前(甚至之后)为驱动程序提供两组配置信息的方法?
谢谢。
【问题讨论】:
标签: c# selenium selenium-webdriver ui-automation firefox-marionette