首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WatiN UnauthorizedAccessException错误

WatiN UnauthorizedAccessException错误
EN

Stack Overflow用户
提问于 2010-11-08 08:47:46
回答 4查看 5K关注 0票数 2

在使用NUnit和WatiN运行任何测试时,我都会遇到UnauthorizedAccessException错误:

代码语言:javascript
复制
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上找不到任何东西,我想知道是否有人遇到过类似的问题?

干杯

EN

回答 4

Stack Overflow用户

发布于 2010-11-08 20:50:25

试试我对其他问题的回答:

尝试关闭IE的保护模式或将站点添加到受信任区域。

WatiN permissions problem when eval javascript code

票数 3
EN

Stack Overflow用户

发布于 2010-11-15 16:19:35

当HTML未完全加载时,可能会发生这种情况。您可以添加睡眠或添加等待完成命令

代码语言:javascript
复制
ie.WaitForComlete();

最好的方法是捕获特定的异常,然后重试:

代码语言:javascript
复制
     try
     {
         //your code
     }
     catch (UnauthorizedAccessException)
     {

     }
票数 2
EN

Stack Overflow用户

发布于 2011-08-11 06:36:56

对我来说,解决方案是卸载我的银行提供的The browser安全软件。我甚至忘了它已经安装好了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4120547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档