Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...