无法安装 Watin for Visual Studio

本文关键字:Visual Studio for Watin 安装 | 更新日期: 2023-09-27 18:37:05

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

这就是我现在所做的:

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

我得到这个错误:

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

你觉得怎么样?

无法安装 Watin for Visual Studio

问题是System.Windows.FormsWatiN.Core都包含Form类的定义。我的建议是删除对WatiN.CoreSystem.Windows.Forms的引用之一,并手动解决如下问题:

System.Windows.Forms.Form form = new System.Windows.Forms.Form();