安装硒WebDriver.ChromeDriver的NuGet包,但没有工作的MSTest [英] Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest

查看:924
本文介绍了安装硒WebDriver.ChromeDriver的NuGet包,但没有工作的MSTest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经加入了 WebDriver.ChromeDriver 的NuGet包我的解决方案,其中包含ChromeDriver.exe文件,硒的webdriver需要使用Chrome运行自动测试。纵观包的内容,它只是包含文件以下文件:

I have added the WebDriver.ChromeDriver nuget package to my solution, which contains the ChromeDriver.exe file, required for Selenium WebDriver to run automated tests using Chrome. Looking at the package contents, it just contains the file following file:

tools\chromedriver.exe

这是什么的应该的做的就是这个文件夹添加到PATH环境变量,以便 chromedriver.exe 的是通过访问下面的代码(这是使用MSTest的一个的UnitTest项目):

What this is supposed to do is add this folder to the PATH environment variable so that chromedriver.exe is accessible via the following code (this is in a UnitTest project using MSTest):

[TestMethod]
public void LaunchWebsite_Chrome()
{
     // create ChromeDriver - this should work if chromedriver.exe 
     // is known to the environment PATH variable
     IWebDriver driver = new ChromeDriver();

     driver.Navigate().GoToUrl("http://localhost/");
}



不过,我仍然得到以下异常:

However, I am still getting the following exception:

chromedriver.exe文件并不在当前目录下或在PATH环境变量的目录存在。驱动程序可以在 http://code.google.com/p/chromium/downloads下载/列表

The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://code.google.com/p/chromium/downloads/list.

综观的NuGet文档,它表明,任何在工具的该包的NuGet文件夹中会得到自动添加到PATH环境变量:

Looking at the nuget documentation, it suggests that anything in the tools folder of the nuget package will get added to the PATH environment variable automatically:

http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package < /一>:一个包的工具文件夹是从包管理器控制台访问的PowerShell脚本和程序。该文件夹复制到目标项目后,它被添加到`$ ENV:路径(PATH)环境变量。

http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package: The tools folder of a package is for powershell scripts and programs accessible from the Package Manager Console. After the folder is copied to the target project, it is added to the `$env:Path (PATH) environment variable.

不过,这似乎并不奏效。我甚至跑在命令行回声%PATH%,并没有显示我的工具文件夹中注册。

However, this doesn't seem to be working. I have even run echo %PATH% on the command line and it doesn't show my tools folder as registered.

我在做什么错了?

推荐答案

我也不会用的NuGet软件包这一麻烦,仅仅是因为这不是类库 - 这在技术上是什么的NuGet是怎么一回事。 。ChromeDriver也已经因为该版本多次更新

I wouldn't bother with the NuGet package for this, simply because this is not a class library - which is technically, what NuGet is all about. ChromeDriver has also been updated many times since that release.

无论如何,我会说,我刚刚做同样的事情,看看有什么问题是:

Anyway, I would say that I have just done the same thing to see what the issue is:


  1. 下载的NuGet包

  2. 使用Visual Studio中,右键单击该项目添加一个新的项目,以项目 - >添加项目 - >现有项

  3. 导航并选择chromedriver.exe

  4. 更改属性,确保复制到输出目录设置为复制总是

  1. Download NuGet package
  2. Using Visual Studio, add a new item to the project by right-clicking on the project -> Add Item -> Existing Item
  3. Navigate and select the chromedriver.exe
  4. Change the properties to ensure "Copy to Output Directory" is set to Copy always.

您很可能坠落在点4.设置为<强>不要复制默认情况下。

You are probably falling down on point 4. That setting is set to Do not copy by default.

这篇关于安装硒WebDriver.ChromeDriver的NuGet包,但没有工作的MSTest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆