【问题标题】:WatiN UnauthorizedAccessException errorsWatiN UnauthorizedAccessException 错误
【发布时间】:2010-11-08 00:47:45
【问题描述】:

我在使用 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).

我似乎无法通过谷歌找到任何东西,想知道是否有人遇到过类似的问题?

干杯

【问题讨论】:

    标签: watin


    【解决方案1】:

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

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

    WatiN permissions problem when eval javascript code

    【讨论】:

      【解决方案2】:

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

      ie.WaitForComlete();
      

      最好的方法是捕获特定异常并再次尝试:

           try
           {
               //your code
           }
           catch (UnauthorizedAccessException)
           {
      
           }
      

      【讨论】:

        【解决方案3】:

        我的解决方案是卸载我的银行提供的 Trusteer Rapport 浏览器安全软件。我忘记了它甚至被安装了。

        【讨论】:

          【解决方案4】:

          我在测试中的随机位置遇到了同样的问题。我已经在可信区域中运行了。

          添加一个

          System.Threading.Thread.Sleep(200);
          

          在每个问题位置“解决”了问题,或者至少对我来说是它的症状。至少我不再收到错误并且能够运行测试。

          这似乎是某处的竞争条件。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2011-10-12
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2010-11-30
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多