编码 ui 测试中的 UITestControlNotAvailableException

UITestControlNotAvailableException in a coded ui test

我在 winforms

中记录的编码 UI 测试进行到一半时出现以下错误

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:

我最初的想法是,这与我试图访问模式 window 中的控件(通过 ShowDialog 显示)这一事实有关,但一个独立的项目证明我错了。我真的不知道如何解决这个问题。有点怀疑错误消息中没有控件名称。

我在 winforms

中记录的编码 UI 测试进行到一半时出现以下错误

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:

我最初的想法是,这与我试图访问模式 window 中的控件(通过 ShowDialog 显示)这一事实有关,但一个独立的项目证明我错了。我真的不知道如何解决这个问题。有点怀疑错误消息中没有控件名称。

编辑:添加了日志记录,所以这里有更多详细信息。这可能与 windows 是一个对话框这一事实有关。

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'

这原来是 Visual Studio 2015 的问题。它在 VS 2012 和 2013 中工作得很好。

万一它是相关的,我试图定位的特定控件是 RadTextbox。