2011-08-26 61 views
1

当我试图与我的网站运行单元测试,我突然开始收到以下错误:使用华廷错误ElementNotFoundException

System.Runtime.InteropServices.COMException was unhandled by user code 
    Message=The interface is unknown. (Exception from HRESULT: 0x800706B5) 
    Source=Interop.SHDocVw 
    ErrorCode=-2147023179 
    StackTrace: 
     at SHDocVw.InternetExplorerClass.set_Visible(Boolean pBool) 
     at WatiN.Core.Native.InternetExplorer.IEBrowser.set_Visible(Boolean value) 
     at WatiN.Core.IE.FinishInitialization(Uri uri) 
     at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess) 
     at WatiN.Core.IE..ctor(String url) 

测试:

WatiN.Core.Exceptions.ElementNotFoundException was unhandled by user code 
    Message=Could not find A element tag matching criteria: Attribute 'href' equals uri  'https://my.companyurl.com/client/clientupload.aspx' at  https://my.companyurl.com/account/default.aspx 
    Source=WatiN.Core 
    StackTrace: 
     at WatiN.Core.Element.get_NativeElement() 
     at WatiN.Core.Element.GetAttributeValueImpl(String attributeName) 
     at WatiN.Core.Component.GetAttributeValue(String attributeName) 
     at WatiN.Core.Element.get_Enabled() 
     at WatiN.Core.Element.ClickImpl(Boolean waitforComplete) 
     at WatiN.Core.Element.Click() 
     at UnitTests.MyUploadFileClass.ClickNavigateToUploadFile() in  D:\DevProjects\MyWebApp\test\UnitTests\Tests\MyUploadFileClass.cs:line 40 
     at UnitTests.MyUploadFileClassTest.UploadNewFileTest() in  D:\DevProjects\MyWebApp\test\UnitTests\Tests\MyUploadFileClassTest.cs:line 110 
    InnerException: 

也受到异常喜欢这个以前通过没有问题,所以我不知道为什么这个错误开始发生。有没有人有什么建议? TIA。

+0

将页面HTML粘贴到此处,听起来好像您没有使用您正在寻找的URI的锚标签 – Jason

回答

2

实际上通过执行三个步骤解决了问题:1)更新了URL,因为我的同事改变了它们。 2)以管理员身份运行Visual Studio。 3)在IE9中进入工具 - > Internet选项 - >安全选项卡 - >本地Intranet。点击网站按钮并从“自动检测Intranet网络”中删除复选框。感谢您的反馈!

+0

仅用于第二步。谢谢。 – Max

0

可能是因为您现在正在使用不同的浏览器或不同的版本。你可以在过去使用的旧浏览器中测试它,看看它是否仍然有效?

+1

没有问题。很高兴它工作。您应该自己发布答案并将其标记为未来访问者的完整答案。 –