重定向到新页面时出现 UnauthorizedAccessException,错误显示在顶部 [英] UnauthorizedAccessException when redirecting to a new page with the error displayed on top

查看:29
本文介绍了重定向到新页面时出现 UnauthorizedAccessException,错误显示在顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用程序位于特定视图,左侧有子菜单,主内容区域中有项目列表.用户需要在单击任何子菜单以导航到子菜单页面之前选择一个项目.如果未选择任何项目并单击子菜单,则服务器应该向 MVC 发布错误并重定向到原始列表页面,并在页面顶部显示错误消息.

The app is at certain view with submenus at the left and a list of items in the main content area. The user needs to select an item before clicking on any of the submenu to navigate to the submenu pages. If no item is selected and a submenu is clicked, the server is supposed to post an error to MVC and redirect to the original list page with the error message displayed on top of the page.

测试只需导航到列表页面,不选择任何项目,立即点击子菜单.

The test simply navigate to the list page, without selecting any item, immediately click on the submenu.

下面的异常被WatiN捕获了,如果我用try/catch块来吃这个异常,会显示原来的列表页面,上面没有显示错误信息.我如何告诉 WatiN 忽略异常,以便错误消息显示在原始列表页面的顶部,就像用户通过手动与没有 WatiN 的服务器交互一样?

The following exception is caught by WatiN, if I use the try/catch block to eat the exception, the original list page would be displayed without the error message displayed on top. How can I tell WatiN to ignore the exception so that the error message would be displayed on top of the original list page, just as user would get by manually interact with the server w/o WatiN?

System.UnauthorizedAccessException 未被用户代码处理Message=访问被拒绝.(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))来源=WatiN.Core堆栈跟踪:在 WatiN.Core.UtilityClasses.UtilityClass.TryFuncFailOver[T](DoFunc1 func, Int32 numberOfRetries, Int32 sleepTime)在 WatiN.Core.Native.InternetExplorer.IEElement.GetWithFailOver[T](DoFunc1 func)在 WatiN.Core.Native.InternetExplorer.IEElement.GetAttributeValue(String attributeName)在 WatiN.Core.Element.GetAttributeValueImpl(String attributeName)在 WatiN.Core.Component.GetAttributeValue(String attributeName)在 WatiN.Core.Element.get_Enabled()在 WatiN.Core.Element.Click()在 C:\ARMS\ARS\QA\Automation\ARMSAutomation\TestAnimals.cs:line 655 中的 ARMSAutomation.TestAnimals.NegativeTestNavigateToAnimalsPanels()内部异常:

System.UnauthorizedAccessException was unhandled by user code Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Source=WatiN.Core StackTrace: at WatiN.Core.UtilityClasses.UtilityClass.TryFuncFailOver[T](DoFunc1 func, Int32 numberOfRetries, Int32 sleepTime) at WatiN.Core.Native.InternetExplorer.IEElement.GetWithFailOver[T](DoFunc1 func) at WatiN.Core.Native.InternetExplorer.IEElement.GetAttributeValue(String attributeName) at WatiN.Core.Element.GetAttributeValueImpl(String attributeName) at WatiN.Core.Component.GetAttributeValue(String attributeName) at WatiN.Core.Element.get_Enabled() at WatiN.Core.Element.Click() at ARMSAutomation.TestAnimals.NegativeTestNavigateToAnimalsPanels() in C:\ARMS\ARS\QA\Automation\ARMSAutomation\TestAnimals.cs:line 655 InnerException:

推荐答案

我认为这是 WatiN 中的一个错误,它阻止了实际单击按钮.这就是为什么您仍然可以看到原始页面的原因.

I think this is a bug in WatiN which prevents the actual clicking on the button. That is why you still see your original page.

尝试升级到最新版本 (2.0.50),其中对元素点击进行了大量更改.

Try upgrading to the latest release (2.0.50) in which a lot of changes regarding the clicking on elements have been made.

HTH,杰伦首席开发人员 WatiN.

HTH, Jeroen Lead dev WatiN.

这篇关于重定向到新页面时出现 UnauthorizedAccessException,错误显示在顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆