适用于Modernui应用程序的CodedUI

时间:2015-06-24 08:12:35

标签: c# coded-ui-tests modern-ui

我正在尝试为ModerUI应用程序创建encodeUI测试用例。 当我尝试运行录制的测试用例时,导航到链接时失败。

无法找到控件或导航到其他链接。 请为此建议任何解决方法。

以下是失败的堆栈跟踪

> Result Message:    Test method
> CodedUITestCases.CodedUITest2.CodedUITestMethod1 threw exception: 
> Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException:
> Cannot perform 'SetProperty of SelectedItemsAsString with value
> "FirstFloor.ModernUI.Presentation.LinkGroup"' on the control.
> Additional Details:  TechnologyName:  'UIA' FrameworkId:  'WPF'
> ControlType:  'List'  --->
> 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.IScreenElement.DoSelectByMouseClick(Object[]
> pArray, String bstrModifierKey)    at
> Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SetValueAsListBox(String[]
> values, Boolean isQueryIdArray)    at
> Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SetValueAsListBox(String[]
> values)    at
> Microsoft.VisualStudio.TestTools.UITesting.TechnologyElementPropertyProvider.SetValueAsListBox(UITestControl
> uiControl, String[] values)    at
> Microsoft.VisualStudio.TestTools.UITesting.WPFListPropertyProvider.SetPropertyValue(UITestControl
> uiTestControl, String propertyName, Object value)    at
> Microsoft.VisualStudio.TestTools.UITesting.UiaPropertyProvider.SetPropertyValue(UITestControl
> uiTestControl, 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)  --- End of inner exception stack
> trace ---
>     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 actionName, UITestControl uiControl)    at
> Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException
> 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__DisplayClass41.<SetProperty>b__40()
> at
> Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](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.WpfControls.WpfList.set_SelectedItemsAsString(String
> value)    at CodedUITestCases.UIMap.DoCalculate() in
> c:\Users\sb803012\AppData\Local\Marine\Code\Application
> Code\LatestWorkingCopy\Marine.ITO.Tool\UT\CodedUITestCasesProject\CodedUITestCases\UIMap.Designer.cs:line
> 301    at CodedUITestCases.CodedUITest2.CodedUITestMethod1() in
> c:\Users\sb803012\AppData\Local\Marine\Code\Application
> Code\LatestWorkingCopy\UT\CodedUITestCasesProject\CodedUITestCases\CodedUITest2.cs:line
> 29

1 个答案:

答案 0 :(得分:0)

您正在设置一个类型组合框(可能是一个选择控件),其值不具备。

注意:组合框项目实际值多次显示为字符串与显示的值不同。

修复: 选择组合框中的项目,然后选中“间谍”以将其actaul值视为字符串(标记组合框并将其选中的值作为字符串属性检查)。

将来 - 当您想要选择该项目时,您需要输入正确的值(已识别)。