![](/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.