Search code examples
watin

Getting started with Watin


I am trying to do the quick start example, I bring in the ref's using NuGet in VS2010, I scrape the sample code on the webpage, I see my NUnit Session window, I click the green arrow, but the browser doesn't get invoked (doesn't start). What am I missing?

using System;  
using NUnit.Framework;  
using WatiN.Core;

namespace FirstWatinProject  
{  
    [TestFixture]  
    public class Class1  
    {  

        [Test]
        [STAThread]
        public void SearchForWatiNOnGoogle()
        {
            using (var browser = new IE("http://www.google.com"))
            {
                browser.TextField(Find.ByName("q")).TypeText("WatiN"); 
                browser.Button(Find.ByName("btnK")).Click(); 
                Assert.IsTrue(browser.ContainsText("WatiN"));
            }
        }

    }
}

I am getting the following error in NUnit Sessions window;

SearchForWaitOnGoogle Failed: System.IO.FileNotFoundException: Could not load file or assembly 'Interop.SHDocVw, Version=1.1.0.0, Culture=neutral etc...


Solution

  • Okay, solved the error, it is as the following other overflow thread concludes; WatiN System.IO.FileNotFoundException Interop.SHDocVw

    BUT, a key action in the sequence is to build the class library project AFTER setting the Interop.SHDocVw dlls' 'Embed Interop Types' property to 'False';

    Then you can hit the green arrow in NUNIT Sessions window and you will see the IE browser startup after a second or two. Simply click it and you will see whatever actions you have programmed.

    God is in the details!