简体   繁体   中英

UITestControlNotAvailableException in a coded ui test

I am getting the following error half way through my recorded Coded UI test in winforms

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException: The following element is no longer available: Name [], ControlType [Window], NativeControlType [window], ClassName [WindowsForms10.Window.8.app.0.2a125d8_r17_ad1], RuntimeId [197812] Additional Details:

My initial thought was that it had something to do with the fact that I am trying to access a control in a modal window (being displayed through ShowDialog) but a standalone project proved me wrong. I really have no idea how to go about fixing this. It is a little suspicions that in the error message there is no control name.

I am getting the following error half way through my recorded Coded UI test in winforms

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException: The following element is no longer available: Name [], ControlType [Window], NativeControlType [window], ClassName [WindowsForms10.Window.8.app.0.2a125d8_r17_ad1], RuntimeId [197812] Additional Details:

My initial thought was that it had something to do with the fact that I am trying to access a control in a modal window (being displayed through ShowDialog) but a standalone project proved me wrong. I really have no idea how to go about fixing this. It is a little suspicions that in the error message there is no control name.

EDIT: Added logging, so here are some more details. This probably has somethign to do with the fact that the windows is a dialog.

Type 'cipher' in 'tbxFedId' text box0:00.376
The following element is no longer available: Name [], ControlType [Window], NativeControlType [window], ClassName [WindowsForms10.Window.8.app.0.2a125d8_r17_ad1], RuntimeId [4260726] Additional Details: TechnologyName: 'MSAA' ControlType: 'Edit'
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException
at Microsoft.VisualStudio.TestTools.UITesting.Playback.AddUITestControlDescriptionToException(Exception exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, Object parameterValue, UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyPrivate(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl+<>c__DisplayClass180_0.<SetProperty>b__0()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod(Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetProperty(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinEdit.set_Text(String value)
at UI.Test.UIMap.RecordedMethod1()
in C:\Users\pg2\Documents\Visual Studio 2015\Projects\ADTrack\UI.Test\UIMap.Designer.cs:line 68
at UI.Test.CodedUITest1.CodedUITestMethod1()
in C:\Users\pg2\Documents\Visual Studio 2015\Projects\ADTrack\UI.Test\CodedUITest1.cs:line 31
The following element is no longer available: Name [], ControlType [Window], NativeControlType [window], ClassName [WindowsForms10.Window.8.app.0.2a125d8_r17_ad1], RuntimeId [4260726]
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException
at Microsoft.VisualStudio.TestTools.UITest.Framework.AbstractUITestService.MapAndThrowException(Exception ex, IUITechnologyElement element)
at Microsoft.VisualStudio.TestTools.UITest.Framework.AbstractUITestService.GetParent(UITechnologyElement element)
at Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.IsDatagridElement(UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.SetEditProperty(String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.SetPropertyValue(UITestControl uiControl, String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.SetPropertyValueWrapper(UITestControl uiControl, String propertyName, Object value)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
Error HRESULT E_FAIL has been returned from a call to a COM component.
System.Runtime.InteropServices.COMException
at Microsoft.VisualStudio.TestTools.UITest.Extension.IUITechnologyManager.GetParent(IUITechnologyElement element)
at Microsoft.VisualStudio.TestTools.UITesting.UITechnologyManagerProxy.GetParent(IUITechnologyElement element)
at Microsoft.VisualStudio.TestTools.UITest.Framework.AbstractUITestService.GetParent(UITechnologyElement element)
The control : "Technology Name: 'MSAA';Search Configuration: 'VisibleOnly'; Search Properties - ControlType : 'Window',ControlName : 'tableLayoutPanel1',Instance : '2'" could not be found under the container : "Search Configuration: 'VisibleOnly'; Search Properties - ControlType : 'Window',Name : 'Employer Picker',ClassName : 'WindowsForms10.Window'".
Technology Name: 'MSAA'
Search Configuration: 'VisibleOnly'
Search Properties -
     ControlType : 'Edit'
Value set : 'cipher'

This turned out to be an issue with Visual Studio 2015. It works just fine in VS 2012 and 2013.

In case it's relevant, the specific control I was trying to target was a RadTextbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM