0

我想为 Visual Studio 2010 安装 Wating。我在网站上看到了他们的视频,并按照步骤操作,但在安装 NuGet 时出现了一些错误。

这就是我现在所做的:

  1. 新项目 -> C# 表单
  2. 项目 -> 添加参考 -> 添加了 Net 4 DLL WatiN.Core.dll
  3. 将此代码添加到我的项目中(来自他们的网站,已添加到下面的源代码中)

我得到这个错误:

'Form' 是 'System.Windows.Forms.Form' 和 'WatiN.Core.Form' 之间的模糊引用 'WatiN.Core.Form' 不包含采用 0 个参数的构造函数当前上下文

这是我的应用程序代码(我也使用 Watin.Core 添加):

    private void Form1_Load(object sender, EventArgs e)
    {

        using (var browser = new IE("http://www.google.com"))
        {
            browser.TextField(Find.ByName("q")).TypeText("WatiN");
            browser.Button(Find.ByName("btnG")).Click();

            Assert.IsTrue(browser.ContainsText("WatiN"));

        }
    }

你怎么看 ?

4

1 回答 1

1

问题是两者都System.Windows.Forms包含WatiN.Core类的定义Form。我的建议是删除两个(其中一个)引用WatiN.CoreSystem.Windows.Forms手动解决问题,如下所示:

System.Windows.Forms.Form form = new System.Windows.Forms.Form();
于 2012-06-14T14:25:52.473 回答