带有便携式FireFox的Selenium.WebDriver c#

时间:2017-06-21 10:40:03

标签: c# selenium firefox

我需要使用Firefox Portable启动Selenium。 如果我使用doubléclic启动Firefox.exe,它就会启动。 Firefox.exe的路径是正确的:Debug项目文件夹中的FireFoxPortable文件夹。

这是我使用的代码:

var driverService = FirefoxDriverService.CreateDefaultService();
driverService.FirefoxBinaryPath = 
    Path.Combine(
        AppDomain.CurrentDomain.BaseDirectory,
        "FireFoxPortable",
        "FireFox.exe");
driverService.HideCommandPromptWindow = true;
driverService.SuppressInitialDiagnosticInformation = true;

var options = new FirefoxOptions();
var driver = new FirefoxDriver(options);

创建驱动程序我有一个例外 - >在PATH或默认安装位置找不到Firefox二进制文件。确保已安装Firefox。操作系统似乎是:Vista

我尝试了这个变种,但没有工作:

var driver = new FirefoxDriver(driverService);

我正在使用这个nuget包: Nuget packages

这是正确的方法吗?

谢谢你的时间!

更新------------------------------------------- -

使用此代码Works:

var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
    "FireFoxPortable", "FireFox.exe");
FirefoxProfile profile = new FirefoxProfile();
var driver = new FirefoxDriver(new FirefoxBinary(path),profile);

但是新FirefoxDriver的警告显示: FirefoxDriver不应该使用FirefoxBinary对象构建。请改用FirefoxOptions。此构造函数将在以后的版本中删除。“

正确的方法是什么?

0 个答案:

没有答案