user5408996
user5408996

Reputation:

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#. 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)      

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

Upvotes: 1

Views: 10118

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193258

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.

Example: SelectElement Class

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

Namespace: OpenQA.Selenium.Support.UI


Assembly: WebDriver.Support (in WebDriver.Support.dll) Version: 3.1.0


Syntax: public class SelectElement : IWrapsElement


Snapshot:

selectelement_class

Solution

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

Reference

You can find relevant discussions in

Upvotes: 2

Related Questions