Error: Found argument '-m' which wasn't expected, or isn't valid in this context while invoking FirefoxDriver and Firefox
Error: Found argument '-m' which wasn't expected, or isn't valid in this context while invoking FirefoxDriver and Firefox
我在使用 Chrome 驱动程序时遇到了一些问题,所以我想切换到 Firefox 驱动程序。我想创建一个无头浏览器,我收到一个我无法解决的错误。
1523632397476 geckodriver INFO geckodriver 0.20.0
1523632397483 geckodriver 信息监听 127.0.0.1:60008
错误:发现参数“-m”不是预期的,或者在此上下文中无效
我这样创建我的驱动程序:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\xxx\geckodriver.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);
我对 Chrome驱动程序做了类似的事情,没有任何问题。
所有版本都是最新的。
你们能告诉我我做错了什么或者告诉我如何在无头模式下创建 FireFox 驱动程序吗?那太棒了!
非常感谢!
根据 FirefoxOptions.BrowserExecutableLocation Property 的 API 文档,它被定义为:
Gets or sets the path and file name of the Firefox browser executable.
所以参数options.BrowserExecutableLocation
必须指向firefox.exe的绝对路径而不是geckodriver.exe
解决方案
因此,如果您的用例是从非标准位置使用 firefox,exe 二进制文件,您可以使用以下代码块:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\path\to\firefox.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);
注意 :您可以在 :
中找到详细的讨论
我在使用 Chrome 驱动程序时遇到了一些问题,所以我想切换到 Firefox 驱动程序。我想创建一个无头浏览器,我收到一个我无法解决的错误。
1523632397476 geckodriver INFO geckodriver 0.20.0 1523632397483 geckodriver 信息监听 127.0.0.1:60008
错误:发现参数“-m”不是预期的,或者在此上下文中无效
我这样创建我的驱动程序:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\xxx\geckodriver.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);
我对 Chrome驱动程序做了类似的事情,没有任何问题。
所有版本都是最新的。
你们能告诉我我做错了什么或者告诉我如何在无头模式下创建 FireFox 驱动程序吗?那太棒了!
非常感谢!
根据 FirefoxOptions.BrowserExecutableLocation Property 的 API 文档,它被定义为:
Gets or sets the path and file name of the Firefox browser executable.
所以参数options.BrowserExecutableLocation
必须指向firefox.exe的绝对路径而不是geckodriver.exe
解决方案
因此,如果您的用例是从非标准位置使用 firefox,exe 二进制文件,您可以使用以下代码块:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\path\to\firefox.exe";
options.AddArgument("--headless");
c._driver = new FirefoxDriver(options);
注意 :您可以在 :
中找到详细的讨论