InteropServices.COMException when running WatiN tests

nunitwatin

When I run WatiN tests on our build server they all throw this InteropServices.COMException:

MyTestClassName.MyTestMethodName:
System.Runtime.InteropServices.COMException : Creating an instance of the COM component with CLSID {0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80004005.

I get the same result wether I run them through TeamCity or I run them manually on the server as an administrator using NUnit GUI (2.5).

This is some sample code:

[TestFixture]
public class MyTestClassName
{
    private string pageUrl;

    [TestFixtureSetUp]
    public void TestFixtureSetUp()
    {
        pageUrl = ConfigurationManager.AppSettings["SiteURL"] + "/Pages/MyPage.aspx";

        Settings.MakeNewIeInstanceVisible = false;
    }

    [Test]
    public void MyTestMethodName()
    {
        using (var ie = new IE(pageUrl))
        {
            ie.SelectList(new Regex(@"^*DropDownList1*$")).Option("TheOption").Select();

            ie.SelectList(new Regex(@"^*DropDownList2*$")).Option("AnOption").Select();

            ie.SelectList(new Regex(@"^*DropDownList3*$")).Option("OtherOption").Select();

        }
    }
}

Any ideas what it can be?

/Joakim

Best Answer

Try running Visual Studio as Administrator.