c# - Selenium - 调用项目 DLL 来运行测试用例 c# 问题
问题描述
我试图通过从 cmd 调用调试 dll 来运行测试用例,但由于我在日志文件中发现的错误,所有测试都失败了:
测试方法 SeleniumUnitTest.SearchTests.SearchByProviderLocationTest 抛出异常:OpenQA.Selenium.DriverServiceNotFoundException:IEDriverServer.exe 文件在当前目录或 PATH 环境变量上的目录中不存在。驱动程序可以在 http://selenium-release.storage.googleapis.com/index.html下载。
说IEDriverServer.exe不存在,但驱动程序已经在 DLL 目录中......当我从 Visual Studio 运行单元测试时我也没有问题。
我运行的命令是:
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe" /testcontainer:"C:\Users\John\Source\Repos\APP\Src\App.TestSelenium\bin\Debug\ App.TestSelenium.dll"
任何想法?
谢谢你。
解决方案
有两种方法可以解决此问题
- 将 InternetExplorer.exe 存储在公共文件夹中并将其添加到环境 PATH 变量中。这是避免将驱动程序存储在解决方案文件夹中的麻烦的最佳方法
但是如果您想更好地控制驱动程序的版本,最好将所有驱动程序放在解决方案根文件夹中,然后在初始化驱动程序时指定路径
var driver = new InternetExplorerDriver((Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
推荐阅读
- php - 如何使用 tc-lib-barcode 指定“X 维度”和“Y 维度”等参数
- c# - 如何在按钮上实现一个按钮,通过相同的点击删除父项和子项,而不需要父项可点击?(统一)
- nativescript - 从 NativeScript vue iOS 中的电子邮件链接打开应用程序
- formula - 有没有办法使用公式字段引用相关记录上的字段中包含的数据?
- typescript - 如何在 Typescript 中映射可能为空的数组
- java - 如何删除 GridLayout 组合中的行之间的间距?
- javascript - 球从中心而不是边缘反弹
- h2o - 得到“原因:java.lang.IllegalStateException:无法加载 HTTP 服务器:在类路径上找不到 HttpServerFacade 的实现。” 错误
- git - git checkout HEAD vs git checkout head
- javascript - 如何处理来自 jQuery Sortable(嵌套列表)的多维数组?