在使用NUnit和WatiN运行任何测试时,我都会遇到UnauthorizedAccessException错误:
Test Test.IndexTests.Can_Do' failed: WatiN.Core.Exceptions.ElementNotFoundException : Could not find INPUT (hidden) or INPUT (password) or INPUT (text) or INPUT (textarea) or TEXTAREA element tag matching criteria: Attribute 'name' equals 'q' at http://www.google.com/ (inner exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)))
----> System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
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_Id()
at WatiN.Core.Element.get_IdOrName()
at WatiN.Core.TextField.TypeText(String value)
Class1.cs(23,0): at Tests.Can_Do()
--UnauthorizedAccessException
at mshtml.IHTMLElementCollection.tags(Object tagName)
at WatiN.Core.Native.InternetExplorer.IEElementCollection.GetElementsByTag(String tagName)
at WatiN.Core.NativeElementFinder.FindElementsByTag(String tagName)
at WatiN.Core.NativeElementFinder.<FindElementByTags>d__0.MoveNext()
at WatiN.Core.ElementFinder.FindFirst()
at WatiN.Core.Element.FindNativeElement()
at WatiN.Core.Element.get_Exists()
at WatiN.Core.Element.<>c__DisplayClass9.<WaitUntilExistsOrNot>b__8()
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try[T](DoFunc`1 func)
0 passed, 1 failed, 0 skipped, took 43.44 seconds (NUnit 2.5.5).我似乎在google上找不到任何东西,我想知道是否有人遇到过类似的问题?
干杯
发布于 2010-11-08 20:50:25
发布于 2010-11-15 16:19:35
当HTML未完全加载时,可能会发生这种情况。您可以添加睡眠或添加等待完成命令
ie.WaitForComlete();最好的方法是捕获特定的异常,然后重试:
try
{
//your code
}
catch (UnauthorizedAccessException)
{
}发布于 2011-08-11 06:36:56
对我来说,解决方案是卸载我的银行提供的The browser安全软件。我甚至忘了它已经安装好了。
https://stackoverflow.com/questions/4120547
复制相似问题