Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
316 views
in Technique[技术] by (71.8m points)

c# - Can't install Watin for Visual Studio

I want to install Wating for Visual Studio 2010. I saw their Video on the website, and followed the steps, but I got some errors while installing NuGet.

This is what I did now:

  1. New project -> C# Form
  2. Project -> Add reference -> Added the Net 4 DLL WatiN.Core.dll
  3. Added this code to my project (from their website, which is added to the source below)

And I get this errors:

'Form' is an ambiguous reference between 'System.Windows.Forms.Form' and 'WatiN.Core.Form' 'WatiN.Core.Form' does not contain a constructor that takes 0 arguments The name 'Assert' does not exist in the current context

Here is my application code (I added using Watin.Core too):

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

        }
    }

What do you think ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The problem is that both System.Windows.Forms and WatiN.Core contain definitions of Form class. My suggestion is to delete both(one of) the references to WatiN.Core and System.Windows.Forms and manually resolve the issues like so:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...