【问题标题】:NUnit error running my c# Selenium WebDriver code运行我的 c# Selenium WebDriver 代码的 NUnit 错误
【发布时间】:2016-07-25 14:23:52
【问题描述】:

我正在使用 Visual Studio 用 C# 编写 Selenium WebDriver 代码,然后将其传递给 NUnit 以运行我的测试。

当我第一次构建和调试我的代码时,它会传递给 NUnit,我可以从那里成功运行(加载正确的浏览器加载正确的网页)

直到最近,每当我尝试在 NUnit 中运行它时,都会出现运行错误:

FirstSeleniumTest.SeleniumTest.TestGoogle:
SetUp : OpenQA.Selenium.WebDriverException : You will need to use add InternetExplorerDriver.UseLegacyInternalServer to the desired capabilities to use the internal native code server library. This functionality will be deprecated in favor of the standalone IEDriverServer.exe server.
  ----> OpenQA.Selenium.DriverServiceNotFoundException : The file C:\Users\lbrown\Documents\Visual Studio 2010\Projects\ClassLibrary15\ClassLibrary15\bin\Debug\IEDriverServer.exe does not exist. The driver can be downloaded at http://code.google.com/p/selenium/downloads/list
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

我下载了它告诉我的驱动程序,但我不确定下一步该做什么或将它放在我的代码中的什么位置。

【问题讨论】:

  • 在我的测试运行良好之前对主题进行了一些研究,它使用的是 Selenium 版本

标签: c# visual-studio selenium selenium-webdriver nunit


【解决方案1】:

解压缩驱动程序,并将其放在与运行测试相同的文件夹中。将其添加到 Visual Studio 中的项目中,确保其构建属性设置为“始终复制”。这将确保它始终与包含测试的已编译 .DLL 文件复制到相同的构建目录。

您可以稍后移动它,但如果它与测试位于同一文件夹中,则它可以正常工作。

【讨论】:

  • 如果不是.dll文件,如何将服务器添加到项目中?
  • 我看到你接受了这个答案,你明白了吗,还是你想让我编辑我的答案以显示我的意思的屏幕截图?
  • 没关系,我找到了应该放置服务器的正确文件夹。
  • Arran 的回答对我来说非常有效。将 IEDriverServer.exe 复制到我的 SeleniumTests 目录中,将属性标志设置为始终复制、重建,然后一切正常。
猜你喜欢
  • 1970-01-01
  • 2017-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-18
相关资源
最近更新 更多