C# Microsoft Web驱动程序已停止工作。在Selenium中使用EdgeDriver和Microsoft Edge时出现错误,导致程序停止正常工作

C# Microsoft Web驱动程序已停止工作。在Selenium中使用EdgeDriver和Microsoft Edge时出现错误,导致程序停止正常工作,c#,selenium,selenium-webdriver,microsoft-edge,selenium-edgedriver,C#,Selenium,Selenium Webdriver,Microsoft Edge,Selenium Edgedriver,如何在Selenium中运行Microsoft Edge。每次运行测试时,边缘浏览器都会打开,但不会加载任何URL。然后将显示一个小对话框,其中包含以下文本: Microsoft Web Driver has stopped working. A problem cause the program to stop working correctly. Please close the program 我正在使用: Windows 10操作系统17763.914 Selenium.WebDri

如何在Selenium中运行Microsoft Edge。每次运行测试时,边缘浏览器都会打开,但不会加载任何URL。然后将显示一个小对话框,其中包含以下文本:

Microsoft Web Driver has stopped working. A problem cause the program to stop working correctly. Please close the program
我正在使用:

  • Windows 10操作系统17763.914
  • Selenium.WebDriver.MicrosoftDriver版本17.17134.0
  • Selenium支持版本3.141.0
  • Selenium Web驱动程序版本3.141.0和
  • Microsoft Edge浏览器版本18.17763
  • 这是一个带有C#的N单元框架
代码试用:

using OpenQA.Selenium.Edge;
driver = new EdgeDriver();
此错误消息

Microsoft Web Driver has stopped working. A problem cause the program to stop working correctly. Please close the program
…表示MicrosoftWebDriver无法启动/生成新的浏览上下文,即Microsoft Edge Browser会话


当您使用Microsoft Edge Browser Version 18.17763时,根据中的文档,现在MicrosoftWebDriver是一个,它可以确保它始终自动更新,并启用一些获取Microsoft WebDriver的新方法

Open Settings app > Go to Update & Security > For Developer and then select "Developer Mode".
台阶
  • 启用开发人员模式,该模式将安装相应版本的WebDriver

    Open Settings app > Go to Update & Security > For Developer and then select "Developer Mode".
    
  • 您还可以通过以下两种方式之一安装独立版本的WebDriver:

    • 从开始搜索“管理可选功能”,然后选择“添加功能”、“WebDriver”
    • 通过在提升的命令提示符下运行以下命令,通过DISM安装:

      DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
      
注意:通过
DISM
命令安装MicrosoftWebDriver时,默认情况下,webdriver安装在以下子目录中:

  • 64位:

    C:\\Windows\\SysWOW64\\MicrosoftWebDriver.exe
    
  • 32位:

    C:\\Windows\\System32\\MicrosoftWebDriver.exe
    

tl;博士 根据:

EdgeHTML 18包括以下新的和更新的功能,这些功能是自(2018年10月,版本17763)起在当前版本的Microsoft Edge平台中提供的。有关特定预览版本中的更改,请参见和


尝试使用chrome?出现此问题的原因是您使用的Microsoft WebDriver版本与Microsoft Edge浏览器版本不匹配。适用于Microsoft Edge版本18的Microsoft WebDriver是Windows随需应变功能。我赞成DebanjanB的答案,你可以尝试他的解决方案中的步骤。谢谢@DebanjanB。我能够按照您的安装步骤安装“WebDriver”,并且能够通过边缘浏览器运行自动化测试。