我正在尝试运行录制的测试用例并且它给我这个错误:(
我无法理解这一点。
请帮忙。
Test Name: CodedUITestMethod1
Test FullName: CanopusCodedUITestProject.CodedUITest1.CodedUITestMethod1
Test Source: d:\CanopusDev\Main\Source\Solutions\CanopusCodedUITestProject\CodedUITest1.cs : line 30
Test Outcome: Failed
Test Duration: 0:00:23.5295373
Result Message:
Test method CanopusCodedUITestProject.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'UIA'
FrameworkId: 'Wpf'
ControlType: 'Window'
Name: 'C5K Setup'
ClassName: 'HwndWrapper'
---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IRPFPlayback.FindAllScreenElements(IScreenElement pScreenElementStart, String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth, Object[]& foundDescendants)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindTopLevelWindowHelper(String queryId)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindFromPartialQueryId(String queryId, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl..ctor(String queryId)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapControlNotFoundException(COMException ex, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String queryId)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl..ctor(String queryId)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.SearchTopLevelWindow(ISearchArgument topLevelSearchArg, String topLevelElementQueryId)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTitleUpdatedTopLevelWindow(ISearchArgument topLevelSearchArg, String queryId, IList`1 windowTitles)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetTopLevelElement(Boolean useCache, Boolean useCacheOnly, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetElement(Boolean useCache, ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.Search(ISearchArgument searchArg)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindInternal()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<Find>b__3a()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.Find()
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyPrivate(String propertyName)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<>c__DisplayClass3e.<GetProperty>b__3d()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
at Microsoft.VisualStudio.TestTools.UITesting.ALUtility.GetTechElementFromUITestControl(UITestControl uiTestControl)
at Microsoft.VisualStudio.TestTools.UITesting.ActionExecutorManager.GetActionExecutor(UITestControl uiControl)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.ClickImplementation(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.<>c__DisplayClass6.<Click>b__5()
at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control, MouseButtons button, ModifierKeys modifierKeys, Point relativeCoordinate)
at Microsoft.VisualStudio.TestTools.UITesting.Mouse.Click(UITestControl control, Point relativeCoordinate)
at CanopusCodedUITestProject.UIMap.CreateConfiguration() in d:\CanopusDev\Main\Source\Solutions\CanopusCodedUITestProject\UIMap.Designer.cs:line 280
at CanopusCodedUITestProject.CodedUITest1.CodedUITestMethod1() in d:\CanopusDev\Main\Source\Solutions\CanopusCodedUITestProject\CodedUITest1.cs:line 32
答案 0 :(得分:0)
看起来您录制的UI组件的属性已更改,因此无法执行录制的操作。验证组件的搜索属性是否仍与录制时相同。
答案 1 :(得分:0)
请查看堆栈跟踪中显示的以下行:
Microsoft.VisualStudio.TestTools.UITesting.Mouse.
Click(UITestControl control, Point relativeCoordinate)
这意味着CodedUI正在尝试使用屏幕上的特定点单击控件。 由于某种原因,它无法找到它想要点击的控件。也许这个特定点上没有按钮。 最有可能的是,当前显示设备的屏幕分辨率与用于记录这些测试的显示设备的屏幕分辨率不同。