C# 在windows主机中运行selenium时,预期浏览器二进制位置出错

C# 在windows主机中运行selenium时,预期浏览器二进制位置出错,c#,selenium,selenium-webdriver,C#,Selenium,Selenium Webdriver,此示例工作: 获取google文本并在主页示例asp.net中显示 在windows主机中测试是否正确工作 我想在承载plesk的windows中运行selenium 我的错误是: “/”应用程序中出现服务器错误 应为浏览器二进制位置,但在默认情况下找不到二进制 位置,没有提供“moz:firefoxOptions.binary”功能,也没有 在命令行上设置的二进制标志(SessionNotCreated) 描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关

此示例工作: 获取google文本并在主页示例asp.net中显示 在windows主机中测试是否正确工作

我想在承载plesk的windows中运行selenium

我的错误是:

“/”应用程序中出现服务器错误

应为浏览器二进制位置,但在默认情况下找不到二进制 位置,没有提供“moz:firefoxOptions.binary”功能,也没有 在命令行上设置的二进制标志(SessionNotCreated)

描述:在执行过程中发生未处理的异常 当前的web请求。请查看堆栈跟踪以了解更多信息 有关错误的信息及其在代码中的来源

异常详细信息:System.InvalidOperationException:应为浏览器 二进制位置,但在默认位置找不到二进制,否 提供了“moz:firefoxOptions.binary”功能,但没有二进制标志 在命令行上设置(SessionNotCreated)

源错误:

在执行过程中生成了未处理的异常 当前web请求。关于货物来源和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。 堆栈跟踪:

[InvalidOperationException:预期的浏览器二进制位置,但 在默认位置找不到二进制文件,否 提供了“moz:firefoxOptions.binary”功能,但没有二进制标志 在命令行上设置(SessionNotCreated)]
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackantRownError(响应 错误响应)+1059
OpenQA.Selenium.Remote.RemoteWebDriver.Execute(字符串 driverCommandToExecute,字典'2参数)+125
OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities 所需能力)+235
OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities desiredCapabilities)+54
OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxOptions) +81 WebDriverwithwebapp.\u默认值。页面\u加载(对象发送者,事件参数)+178
System.Web.Util.CallEventHandlerDelegateProxy.Callback(对象发送方, EventArgs e)+51 System.Web.UI.Control.OnLoad(EventArgs e)+95
System.Web.UI.Control.LoadRecursive()+59
System.Web.UI.Page.ProcessRequestMain(布尔值 IncludeStages前同步点,布尔值IncludeStages后同步点) +678


尝试将
选项
变量传递到
新FirefoxDriver()的参数中。
。这对我来说是这样的:

FirefoxOptions options = new FirefoxOptions();
    options.BrowserExecutableLocation = ("C:\\Program Files\\Mozilla Firefox\\firefox.exe"); //This is the location where you have installed Firefox on your machine

   // WebDriver driver = new FirefoxDriver(options);

    using (var FireFoxPage = new FirefoxDriver(options))
    {
   //...

实际上,我看到一个使用
options
对象的已注释变量,您使用它时是否有任何错误?

该错误表明firefox可执行文件的路径错误。你检查过它是否正确了吗?Firefox是否也安装在您希望执行代码的服务器上?运行到windows hosting plesk。没有解决方案<代码>未知错误:找不到Chrome二进制文件(驱动程序信息:chromedriver=2.41.578737(49da6702b16031c40d63e5618de03a32ff6c197e),平台=Windows NT 10.0.14393 x86_64)
FirefoxOptions options = new FirefoxOptions();
    options.BrowserExecutableLocation = ("C:\\Program Files\\Mozilla Firefox\\firefox.exe"); //This is the location where you have installed Firefox on your machine

   // WebDriver driver = new FirefoxDriver(options);

    using (var FireFoxPage = new FirefoxDriver(options))
    {
   //...