watin nunit UnauthorizedAccessException:访问被拒绝

发布于 2024-12-03 16:35:04 字数 1614 浏览 0 评论 0原文

我开始在通过 Nunit 运行 Watin 测试时遇到问题。上周这是有效的,但本周却无效了。我不知道我已经更改了任何内容,但我开始收到 UnauthorizedAccessException :当我尝试单击链接时出现访问被拒绝错误。

引发错误的最简单代码如下:

[Test, RequiresSTA]
public void TestTest()
{
  using (var browser = new IE(SMDTestConfig.TestURL + "Game"))
  {
    browser.Link(Find.ByText("Log On")).Click();
  }
}

NUnit 的完整错误消息如下:

SMDTestFramework.GameTest.TestTest: WatiN.Core.Exceptions.ElementNotFoundException:找不到 A 元素标记匹配条件:属性“innertext”与 http://localhost/smdci/Game(内部异常:访问被拒绝。(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))) ----> System.UnauthorizedAccessException :访问被拒绝。 (HRESULT 的异常:0x80070005 (E_ACCESSDENIED))

错误消息表明是 Find.ByText("Log On") 语句导致了错误,但如果我将其分成两行,如下所示:

AttributeConstraint cons = Find.ByText("Log On");
browser.Link(cons).Click();

错误实际上是在第二行。

我查看了以下问题,但似乎没有一个答案对我有用:

WatiN UnauthorizedAccessException 错误

访问被拒绝错误(Visual Studio 和 WatiN)

重定向到新页面时出现 UnauthorizedAccessException,并显示错误顶部

四处走动System.UnauthorizedAccessException:访问被拒绝

I've started having trouble running Watin tests via Nunit. Last week this was working but this week it's not. I'm not aware that I've changed anything but I've started getting UnauthorizedAccessException : access is denied errors being raised when I'm trying to click a link.

The simplest code that raises the error is as follows:

[Test, RequiresSTA]
public void TestTest()
{
  using (var browser = new IE(SMDTestConfig.TestURL + "Game"))
  {
    browser.Link(Find.ByText("Log On")).Click();
  }
}

The full error message from NUnit is as follows:

SMDTestFramework.GameTest.TestTest:
WatiN.Core.Exceptions.ElementNotFoundException : Could not find A element tag matching criteria: Attribute 'innertext' matches '^ *Log\ On *$' at http://localhost/smdci/Game (inner exception: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)))
----> System.UnauthorizedAccessException : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The error message would suggest that it's the Find.ByText("Log On") statement that's causing the error but if I split it up into 2 lines as follows:

AttributeConstraint cons = Find.ByText("Log On");
browser.Link(cons).Click();

The error is actually raised on the second line.

I've looked at the following questions but none of the answers seem to work for me:

WatiN UnauthorizedAccessException errors

Access denied error ( Visual Studio and WatiN )

UnauthorizedAccessException when redirecting to a new page with the error displayed on top

Getting around System.UnauthorizedAccessException : Access is denied

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文