![](/img/trans.png)
[英]'the type or namespace could not be found' in Visual Studio 2017
[英]The type or namespace name 'IWebDriver' could not be found error while executing Nunit test through Selenium on Visual Studio 2017
我正在尝试使用 C# 在 mac 上使用 selenium 创建一些测试用例。 我使用的 IDE 是 Visual Studio 2017。我安装了以下软件包,selenium web 驱动程序,selenium 支持,selenium firefox web 驱动程序。 我的问题是如何成功使用 selenium 为使用 C# 的网站创建测试用例。 每当我尝试运行测试用例时,都会弹出以下错误;
/Users/andrew/Projects/test/test/Test.cs(23,23): Error CS0234: The type or namespace name 'Firefox' does not exist in the namespace 'OpenQA.Selenium' (are you missing an assembly reference?) (CS0234) (test)
和
/Users/andrew/Projects/test/test/Test.cs(9,9): Error CS0246: The type or namespace name 'IWebDriver' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (test)
代码试用:
using NUnit.Framework;
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace test
{
[TestFixture()]
public class Test
{
IWebDriver driverOne = new FirefoxDriver();
[Test()]
public void TestCase()
{
driverOne.Navigate().GoToUrl("http://google.com/");
}
}
}
参考之前的一些帖子,如果您通过Visual Studio 2017 、 nunittestadapter 、 NUnit.Framework 、 VS 2017等框架使用Selenium-WebDriver ,使用 NuGet 管理器,有时可能会出现安装/配置问题。
根据文档, SelectElement
类在OpenQA.Selenium.Support.UI Namespace
几乎可用,它提供了一种方便的方法来操作 HTML 选择元素中的选项选择。
继承层次结构
System.Object
OpenQA.Selenium.Support.UI.SelectElement
命名空间: OpenQA.Selenium.Support.UI
程序集: WebDriver.Support(在 WebDriver.Support.dll 中)版本:3.1.0
语法:公共类 SelectElement : IWrapsElement
快照:
卸载并重新安装 Selenium.Webdriver 和 Selenium.Support 包,这肯定会解决问题。
您可以在
从 Selenium.WebDriver 4.0 开始,需要同时安装 Selenium.WebDriver 和 Selenium.Support nuget 包(相同版本)以避免此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.