UnauthorizedAccessException when redirecting to a

2019-08-16 01:58发布

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.

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 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
1条回答
叼着烟拽天下
2楼-- · 2019-08-16 02:27

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.

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

HTH, Jeroen Lead dev WatiN.

查看更多
登录 后发表回答