Setting BrowserExecutableLocation in FirefoxOptions in Selenium does not prevent "Cannot find matching feature set" error

I'm still fairly new to Selenium and trying to create some minimally passing test cases (I think you could call them the equivalent of a "hello world" program in a way).

I tried to instantiate the Firefox driver like this:

var options = new FirefoxOptions()
{
    BrowserExecutableLocation = @"C:\Program Files(x86)\Mozilla Firefox\Firefox.exe",
    Profile = new FirefoxProfile(),
    LogLevel = FirefoxDriverLogLevel.Debug
};

firefoxDriver = new FirefoxDriver(options);

      

However, when I run the test, I got the following error: Unable to find a matching set of capabilities

. Several other answers I read in Stack Overflow and elsewhere have suggested that the way to fix this is to explicitly specify the location of the binary, like so:

firefoxDriver = new FirefoxDriver(new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"), new FirefoxProfile());

      

When I try this it works, but I get the following compiler warning:

Warning CS0618 'FirefoxDriver.FirefoxDriver(FirefoxBinary, FirefoxProfile)' is obsolete: 'FirefoxDriver should not be constructed with a FirefoxBinary object. Use FirefoxOptions instead. This constructor will be removed in a future release.'

If the second version works, why is the first version not working, given what I clearly pointed out BrowserExecutableLocation

in FirefoxOptions

? Is there a way to do something like the first way I tried to work with to avoid using the second, deprecated constructor?

FWIW, I am using Firefox 52.2.0 and my NuGet packages are installed like this:

<packages>
  <package id="Selenium.Firefox.WebDriver" version="0.18.0" targetFramework="net452" />
  <package id="Selenium.WebDriver" version="3.4.0" targetFramework="net452" />
  <package id="Selenium.WebDriver.IEDriver" version="3.4.0" targetFramework="net452" />
</packages>

      

+1


source to share


1 answer


If you're trying to use FirefoxOptions in particular, try this constructor:

FirefoxDriver(FirefoxDriverService service, FirefoxOptions options, TimeSpan commandTimeout);

      

The following didn't work for me:



FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Path to Gecko);
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
driver = new FirefoxDriver(service);

      

However, the following works well:

FirefoxDriverService service = FirefoxDriverService.CreateDefaultService("Gecko Path");
FirefoxOptions options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe";
driver = new FirefoxDriver(service, options, TimeSpan.FromMinutes(1));

      

+1


source







All Articles