在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

查看:194
本文介绍了在Visual Studio 2017上通过Selenium执行Nunit测试时找不到类型或名称空间名称'IWebDriver'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#在Mac上使用硒创建一些测试用例.我正在使用的IDE是visual Studio2017.我安装了以下软件包,selenium Web驱动程序,selenium支持,selenium firefox Web驱动程序.我的问题是如何使用C#成功使用硒为网站创建测试用例.每当我尝试运行测试用例时,都会弹出以下错误;

I am trying to create some test cases with selenium on a mac with C#. The IDE I am using is visual studio 2017. I have the following packages installed , selenium web driver, selenium support, selenium firefox web driver. My Question is how do I successfully use selenium to create test cases for website using 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)      

/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 ,使用NuGet Manager的 VS 2017 ,有时安装/配置可能会出现问题.

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.

根据文档, SelectElement OpenQA.Selenium.Support.UI Namespace ,它提供了一种方便的方法来处理HTML select元素中的选项选择.

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.

继承层次结构

Inheritance Hierarchy

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


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


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


语法:公共类SelectElement:IWrapsElement


快照:


Snapshot:

卸载&重新安装Selenium.Webdriver和Selenium.Support软件包,这肯定会解决该问题.

Uninstall & reinstall the Selenium.Webdriver and Selenium.Support packages, that will surely fix the problem.

您可以在

这篇关于在Visual Studio 2017上通过Selenium执行Nunit测试时找不到类型或名称空间名称'IWebDriver'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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