watin nunit UnauthorizedAccessException:访问被拒绝
我开始在通过 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)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论