WebDriver Portable Firefox c#

时间:2017-07-08 21:43:11

标签: c# selenium selenium-webdriver webdriver

我尝试加载Portable Firefox

FirefoxProfile profile = new FirefoxProfile();
var binary = new FirefoxBinary(Directory.GetCurrentDirectory()+ @"\FirefoxPortable64\FirefoxPortable.exe");

var driver = new FirefoxDriver(binary, profile);

但我在第Unable to find a matching set of capabilities

中收到错误var driver = new FirefoxDriver(binary, profile); 你可以帮我吗?

var driver = new FirefoxDriver(binary, profile);行中,我有警告:

  

FirefoxDriver不应该使用FirefoxBinary对象构建。请改用FirefoxOptions。此构造函数将在以后的版本中删除。

我怎么能重写代码?

UPD: 我重写了代码:

FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
options.Profile = profile;
options.BrowserExecutableLocation = Directory.GetCurrentDirectory() + @"\FirefoxPortable64\FirefoxPortable.exe";
var driver = new FirefoxDriver( options);

但它不起作用,再次出现错误Unable to find a matching set of capabilities

1 个答案:

答案 0 :(得分:0)

解决方案;

 options.BrowserExecutableLocation = Directory.GetCurrentDirectory() + @"\FirefoxPortable32\App\Firefox\firefox.exe";