Problem calling CassiniDev from WatiN

Dec 12, 2010 at 6:48 PM

I have created a small demo project to try out using NUnit plus WatiN to call an ASP.NET Web Forms application hosted in CassiniDev.

WatiN doesn't seem to be able to "see" the pages hosted in the CassiniDev server.

In my example, I start up the CassiniDev server pointed at the Web App directory.  One test using the WebClient object (from System.Net) successfully retrieves the HTML of my test page.  However, the other test in the fixture opens IE (in process) using WatiN but recieves nothing back after hitting the same URL.  The IE instance that opens up just sits at a white page.

If I try to hit another URL with WatiN (e.g. google.com) the page is returned as expected.  So, it seems like CassiniDev is correctly hosting the Web App (because WebClient can see it) and it seems that WatiN is working correctly (because it can hit other websites), but, it seems that WatiN is not able to hit the CassiniDev server.

Has anyone come across this issue before or got any ideas what could be going wrong?

The test fixture I am using currently looks as follows:

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

namespace CassiniDevSystemTests
{
    [TestFixture]
    public class TestClass
    {
        private CassiniDevServer _hostServer;

        [TestFixtureSetUp]
        public void SetUpAllTests()
        {
            _hostServer = new CassiniDevServer();
            string webAppPath = @"..\..\..\DemoSite\";
            _hostServer.StartServer(webAppPath);
        }

        [Test]
        public void TestUsingWebClient()
        {
            string url = _hostServer.NormalizeUrl("Default.aspx");

            WebClient wc = new WebClient();
            string actual = wc.DownloadString(url);

            Assert.IsTrue(actual.Contains("this is default.aspx"));
        }

        [Test]
        public void TestUsingWatin()
        {
            string url = _hostServer.NormalizeUrl("Default.aspx");

            IE browser = new IE(false);
            browser.GoTo(url);
            browser.WaitForComplete();
            var actual = browser.Html;
           
            Assert.IsTrue(actual.Contains("this is default.aspx"));
        }
    }
}

Dec 16, 2010 at 7:13 PM

Found a fix for my issue. In IE8 go to  Tools->Internet Options->Security tab->Local Intranet. Click "Sites" button and uncheck "Automatically detect intranet network".  (I've read that running Visual Studio as an Administrator is an alternative workaround.)

I discovered this as a side-effect of fixing an System.Runtime.InteropServices.COMException was unhandled by user code Message="The interface is unknown. (Exception from HRESULT: 0x800706B5)" error that I was getting when WatiN hit IIS Express.  (Details here: http://stackoverflow.com/questions/1014815/how-do-you-get-watin-to-work-on-windows-server-2008-with-ie8/1574448#1574448)

Hopefully this will save a bit of time for anyone else that runs into it.

Coordinator
Dec 17, 2010 at 2:30 AM

stevie, I am sorry I was not available to investigate this but it seems that you have done more than I would likely have been able to (in any timely fashion). I typically accept the 'intranet settings' prompt on IE the first time I see it, which is why I have never seen this issue and would likely have stumbled around looking for it.

 

Thanks for the detailed description and workaround. I fear that there is not a more elegant way to deal with this.

Cheers,

Sky