简体   繁体   English

找不到类型或命名空间名称“NUnit”

[英]The type or namespace name 'NUnit' could not be found

I have ac# code.(which is exported from selenium IDE)我有 ac# 代码。(从 selenium IDE 导出)

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace SeleniumTests
{
[TestFixture]
public class csharp
{
private ISelenium selenium;
private StringBuilder verificationErrors;

[SetUp]
public void SetupTest()
{
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost:1924/");
selenium.Start();
verificationErrors = new StringBuilder();
}

[TearDown]
public void TeardownTest()
{
try
{
selenium.Stop(); 
}
catch (Exception)
{
// Ignore errors if unable to close the browser
}
Assert.AreEqual("", verificationErrors.ToString());
}

[Test]
public void TheCsharpTest()
{
        selenium.Open("/cookie/Default.aspx");
        selenium.Type("id=TextBox1", "ranadheer");
        selenium.Type("id=TextBox2", "SE");
        selenium.Type("id=TextBox3", "hyderabad");
        selenium.Click("id=Button1");
        selenium.WaitForPageToLoad("30000");
        selenium.Click("id=Button2");
        selenium.WaitForPageToLoad("30000"); 
}
}
}

I pasted this code in a console application (visual studio 2008).我将此代码粘贴到控制台应用程序(visual studio 2008)中。
After running, I got this errors:运行后,我收到此错误:

The type or namespace name 'NUnit' could not be found.找不到类型或命名空间名称“NUnit”。
The type or namespace name 'TestFixture' could not be found找不到类型或命名空间名称“TestFixture”
The type or namespace name 'ISelenium' could not be found找不到类型或命名空间名称“ISelenium”
The type or namespace name 'SetUpAttribute' could not be found找不到类型或命名空间名称“SetUpAttribute”

What framework should I add to correct this errors?我应该添加什么框架来纠正这个错误?

It seems like you have references missing.似乎您缺少参考资料。 From official Selenium docs page :从官方硒文档页面

Add references to the following DLLs: nmock.dll, nunit.core.dll, nunit.添加对以下 DLL 的引用:nmock.dll、nunit.core.dll、nunit。 framework.dll, ThoughtWorks.Selenium.Core.dll, ThoughtWorks.Selenium.IntegrationTests.dll and ThoughtWorks.Selenium.UnitTests.dll framework.dll、ThoughtWorks.Selenium.Core.dll、ThoughtWorks.Selenium.IntegrationTests.dll 和 ThoughtWorks.Selenium.UnitTests.dll

For your current problem, you need to reference at least NUnit.Framework.dll and Selenium dlls.对于您当前的问题,您至少需要引用 NUnit.Framework.dll 和 Selenium dll。

Please read the docs page for more info.请阅读文档页面了解更多信息。

Right click on references in the solution explorer and click add reference.右键单击解决方案资源管理器中的引用,然后单击添加引用。 You will need to browse for the nunit.framework.dll您需要浏览 nunit.framework.dll

您需要添加对 NUNIT dll 的引用

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM