2

I'm trying to use Selenium in C# and I get the following error,

System.InvalidOperationException: 'Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (SessionNotCreated)'

what could it be?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Ashkan
  • 37
  • 1
  • 6

2 Answers2

2

This error message...

System.InvalidOperationException: 'Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line (SessionNotCreated)'

...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. Firefox Browser session.

Possibly browser is installed at a non-conventional location, hence GeckoDriver is unable to access the firefox binary.


Solution

As a solution pass the absolute location of the firefox.exe binary through the BrowserExecutableLocation argument of FirefoxOptions as follows:

FirefoxOptions options = new FirefoxOptions();
options.BrowserExecutableLocation = ("C:\\Program Files\\Mozilla Firefox\\firefox.exe"); //location where Firefox is installed
WebDriver driver = new FirefoxDriver(options);
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
1

You need download Mozilla Firefox

https://www.mozilla.org/en-US/firefox/new/

then install Mozilla Firefox.

Vy Do
  • 46,709
  • 59
  • 215
  • 313