C# 无法使用chrome驱动程序85和chrome浏览器版本85初始化chrome驱动程序
当执行任何测试脚本时。chrome驱动程序未初始化并在visual studio 2019中引发null异常C# 无法使用chrome驱动程序85和chrome浏览器版本85初始化chrome驱动程序,c#,selenium,selenium-chromedriver,C#,Selenium,Selenium Chromedriver,当执行任何测试脚本时。chrome驱动程序未初始化并在visual studio 2019中引发null异常 Message: Test method threw exception: System.NullReferenceException: Object reference not set to an instance of an object. TestCleanup method threw exception. System.NullReferen
Message:
Test method threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
TestCleanup method threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)
对goolge.com执行任何selenium UI测试用例
下面是我在VisualStudio2019中遇到的错误
Message:
Test method threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
TestCleanup method threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)
复制行为的详细步骤:
预期行为
chrome驱动程序应在visual studio 2019中初始化
Message:
Test method threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
TestCleanup method threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)
复制此问题的测试脚本或命令集
如果
设置更复杂,GitHub repo链接也可以
[TestInitialize]
public static IWebDriver NavigateTo(string browser)
{
//accessing the web driver from the solution directory
var currentPath = Directory.GetCurrentDirectory();
try
if (browser.Contains("Chrome"))
{
ChromeOptions options = new ChromeOptions();
options.AddArguments(/*"--headless",*/ "--disable-gpu", "--window-size=1920,1200", "--ignore-certificate-errors", "--silent");
options.PageLoadStrategy = PageLoadStrategy.Default;
driver = new ChromeDriver(currentPath, options);
}
catch (Exception e)
{
_ = e.StackTrace;
}
return driver;
}
环境
操作系统:Windows 10
浏览器:Chrome版本85.0.4183.83(官方版本)(64位)
浏览器版本:版本85.0.4183.83(正式版本)(64位)
浏览器驱动程序版本:ChromeDriver 85.0.4183.87
语言绑定版本:C#Visual Studio 2019问题已解决=nuget软件包未更新chrome驱动程序,即使它显示为最新版本。nuget显示最新的chrome驱动程序正在更新。但是在bin文件夹中。这实际上是旧版本。我不得不重新启动我的VisualStudio并卸载nuget软件包,然后重新安装修复了这个问题。谢谢您的帮助驱动程序是否在同一文件夹中?是否为c#可执行文件?我认为下面的行失败了:driver=newchromedriver(currentPath,options);请参阅错误日志,其中提到此版本的ChromeDriver仅支持ChromeVersion83(SessionNotCreated)。因此,我认为您必须升级chrome驱动程序或降级chrome版本。@jdweng是的,它使用的是当前目录,即我的用户文件夹。我调试了它,路径显示正确。@dilimpeghwal我有最新版本的chrome浏览器版本85和chrome驱动程序版本85。我无法在这里上传我的截图。我不会的。你是在手动添加chromedriver吗?你为什么不使用nuget?
Message:
Test method threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
TestCleanup method threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
session not created: This version of ChromeDriver only supports Chrome version 83 (SessionNotCreated)