Search code examples
c#internet-explorerc#-4.0watin

WATIN keeps crashing with HRESULT: 0x80070005 (E_ACCESSDENIED)


I keep getting this on IE6 using Windows XP

WatiN.Core.Exceptions.RunScriptException : RunScript failed
  ----> System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I added my domain to the Trusted Sites but still same issue.

This error didn't happen with Windows 7 64-bit with IE9

Here is where it crashes

 browser.Image(Find.ByAlt("Use a password")).Click();
 browser.TextField(Find.ByName("_MYPW")).TypeText(privateCurrentPassword); // CRASHES HERE

Solution

  • I have had trouble with this before and its because i was using local variables between postbacks to store the references to the elements.

    don't do this

        var btn Browser.Button("clientid")
        btn.Click(); //assume that this triggers a postback
        var result = btn.Text;
    

    do this

        Browser.Button("clientid").Click();
        result = Browser.Button("clientid").Text;