Schippert
Schippert

Reputation: 75

Error: Found argument '-m' which wasn't expected, or isn't valid in this context while invoking FirefoxDriver and Firefox

I had some issues with the Chrome driver so I want to make a switch to the Firefox driver. I want to create a headless browser with im getting an error that I cannot resolve.

1523632397476 geckodriver INFO geckodriver 0.20.0 1523632397483 geckodriver INFO Listening on 127.0.0.1:60008

error: Found argument '-m' which wasn't expected, or isn't valid in this context

I create my driver like this:

var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\xxx\geckodriver.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);

I did something similar with the ChromeDriver without any issue.

All the versions are up to date.

Can you guys tell me what I am doing wrong or show me how to create a FireFox driver in headless mode. That would be awesome!

Thanks a lot!

Upvotes: 2

Views: 6176

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193128

As per the API Docs of FirefoxOptions.BrowserExecutableLocation Property it is defined as :

Gets or sets the path and file name of the Firefox browser executable.

So the argument options.BrowserExecutableLocation must point to the absolute path of firefox.exe but not geckodriver.exe

Solution

So if your usecase is to use the firefox,exe binary from a non-standard location you can use the following code block :

var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\path\to\firefox.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);

Note : You can find detailed discussions in :

Upvotes: 2

Related Questions