title: Intermittent IE timeouts and COMExceptions when running Watin tests with Nant and CruiseControl
body: <p>We’ve been using Watin and CruiseControl.net for a few weeks now and most of the time they work together well.  We have not had any problems running the tests on our developer machines. We are also able to run the tests interactively without problems when logged into the CI server. </p>
  
  <p>Most of the time there are also no problems when the tests are executed under CruiseControl but this is not always the case as we’ve recently been seeing intermittent errors. The errors seem to come and go somewhat randomly but when an error does occur, it’s always one of the following:</p>
  
  <ol>
  <li><p>WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy</p></li>
  <li><p>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: 800704a6</p></li>
  </ol>
  
  <p>Our CI server environment is:</p>
  
  <ul>
  <li><p>Windows Server 2008 R2</p></li>
  <li><p>IIS 7.5</p></li>
  <li><p>IE 8</p></li>
  <li><p>Watin 2.0</p></li>
  <li><p>CruiseControl 1.6.7981.1. This is running as a service which logs in as a user on our domain because the tests need to access resources on the domain.</p></li>
  </ul>
  
  <p>The 'randomly' failing tests create their IE instances as follows:</p>
  
  <pre><code>    [TestMethod]
      public void SomeTest()
      {
          using (var browser = new IE())
          {
              // run tests here
          }
      }
  </code></pre>
  
  <p>I also tried creating the IE in a new process as follows:</p>
  
  <pre><code>    [TestMethod]
      public void SomeTest()
      {
          using (var browser = new IE( true))
          {
              // run tests here
          }
      }
  </code></pre>
  
  <p>But when I did that, <em>all</em> of our tests failed with a “WatiN.Core.Exceptions.BrowserNotFoundException: Could not find an IE window matching constraint: Timeout while waiting to attach to newly created instance of IE.. Search expired after '30' seconds”</p>
  
  <p>So, I have two questions:</p>
  
  <ol>
  <li>Can anyone tell me  how I can stop the timeouts and com exceptions?</li>
  <li>Can anyone explain why IE(true) didn’t work at all?</li>
  </ol>
  
  <p>TIA,
  Mike</p>