1

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
  • 151,581
  • 34
  • 225
  • 281
Ashkan
  • 27
  • 6

2 Answers2

1

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
  • 151,581
  • 34
  • 225
  • 281
0

You need download Mozilla Firefox

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

then install Mozilla Firefox.

James Graham
  • 39,063
  • 41
  • 167
  • 242