简体   繁体   English

在 Visual Studio 2017 上通过 Selenium 执行 Nunit 测试时,找不到类型或命名空间名称“IWebDriver”错误

[英]The type or namespace name 'IWebDriver' could not be found error while executing Nunit test through Selenium on Visual Studio 2017

I am trying to create some test cases with selenium on a mac with C#.我正在尝试使用 C# 在 mac 上使用 selenium 创建一些测试用例。 The IDE I am using is visual studio 2017. I have the following packages installed , selenium web driver, selenium support, selenium firefox web driver.我使用的 IDE 是 Visual Studio 2017。我安装了以下软件包,selenium web 驱动程序,selenium 支持,selenium firefox web 驱动程序。 My Question is how do I successfully use selenium to create test cases for website using C#.我的问题是如何成功使用 selenium 为使用 C# 的网站创建测试用例。 Whenever I try to run the test cases, the following errors pop up ;每当我尝试运行测试用例时,都会弹出以下错误;

/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)      

and

/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)

Code trial:代码试用:

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/");
        }
    }
}

Referring to a few previous posts it seems if you are using Selenium-WebDriver through frameworks like Visual Studio 2017 , nunittestadapter , NUnit.Framework , VS 2017 using the NuGet Manager sometimes there can be issues with the installation /configuration.参考之前的一些帖子,如果您通过Visual Studio 2017nunittestadapterNUnit.FrameworkVS 2017等框架使用Selenium-WebDriver使用 NuGet 管理器,有时可能会出现安装/配置问题。

Example: SelectElement Class示例:SelectElement 类

As per the documentation the SelectElement Class is pretty much available within OpenQA.Selenium.Support.UI Namespace which provides a convenience method for manipulating selections of options in an HTML select element.根据文档, SelectElement类在OpenQA.Selenium.Support.UI Namespace几乎可用,它提供了一种方便的方法来操作 HTML 选择元素中的选项选择。


Inheritance Hierarchy继承层次结构

System.Object
    OpenQA.Selenium.Support.UI.SelectElement

Namespace: OpenQA.Selenium.Support.UI命名空间: OpenQA.Selenium.Support.UI


Assembly: WebDriver.Support (in WebDriver.Support.dll) Version: 3.1.0程序集: WebDriver.Support(在 WebDriver.Support.dll 中)版本:3.1.0


Syntax: public class SelectElement : IWrapsElement语法:公共类 SelectElement : IWrapsElement


Snapshot:快照:

选择元素类

Solution解决方案

Uninstall & reinstall the Selenium.Webdriver and Selenium.Support packages, that will surely fix the problem.卸载并重新安装 Selenium.Webdriver 和 Selenium.Support 包,这肯定会解决问题。

Reference参考

You can find relevant discussions in您可以在

从 Selenium.WebDriver 4.0 开始,需要同时安装 Selenium.WebDriver 和 Selenium.Support nuget 包(相同版本)以避免此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio 2017 中找不到“类型或命名空间” - 'the type or namespace could not be found' in Visual Studio 2017 Visual Studio 2017 构建到 hololens 错误 CS0246“找不到类型或命名空间名称 'UnityPlayer'” - Visual studio 2017 building to hololens error CS0246 "The type or namespace name 'UnityPlayer' Could not be found" 错误:在Visual Studio 2013中找不到类型或命名空间名称“ApplicationUser” - Error: The type or namespace name 'ApplicationUser' could not be found in Visual Studio 2013 找不到类型或命名空间名称“NUnit”| 统一 - The type or namespace name 'NUnit' could not be found | Unity 找不到类型或命名空间名称“NUnit” - The type or namespace name 'NUnit' could not be found 在 MSBuild 中找不到类型或命名空间名称,但在 Visual Studio 中有效 - The type or namespace name could not be found in MSBuild but works in Visual Studio Visual Studio 代码:找不到类型或命名空间名称“IntPtr” - Visual Studio Code: The type or namespace name 'IntPtr' could not be found 在 Visual Studio Code for Mac 上找不到类型或命名空间名称“System” - The type or namespace name 'System' could not be found on Visual Studio Code for Mac Visual Studio Code Do.net Core C# 错误:“找不到类型或命名空间名称‘System’”,但构建成功 - Error in Visual Studio Code Dotnet Core C#: "The type or namespace name 'System' could not be found", but build succeeds 构建后的 Visual Studio 出现错误 CS0246:找不到类型或命名空间名称? - Visual studio after building give error CS0246: The type or namespace name could not be found?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM