无法使用 FirefoxProfile 和 FirefoxDriverService 实例化 Marionette 驱动程序



我目前正在用新的Firefox木偶驱动程序更新我的c#解决方案。

我已经设法让驱动程序成功地启动一个url与以下代码

        FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Directory.GetCurrentDirectory(),"wires-0.6.0-win.exe");
        service.FirefoxBinaryPath = @"C:Program Files (x86)Mozilla Firefoxfirefox.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。有人知道我可以设法在创建驱动程序之前(甚至之后)给驱动程序两组配置信息的方法吗?

谢谢。

这是使用FirefoxProfile的示例代码&FirefoxDriverService。我想隐藏命令提示窗口和静音

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
FirefoxProfile _Profile = new FirefoxProfile();
_Profile.SetPreference("media.volume_scale", "0.0");
FirefoxOptions option = new FirefoxOptions();
option.Profile = _Profile;
var driver = new FirefoxDriver(service,option,TimeSpan.FromSeconds(20));
driver.Navigate().GoToUrl("https://www.youtube.com/watch?v=hxiitzCKRek");

相关内容

  • 没有找到相关文章

最新更新