I am trying to create codedUI test cases for ModerUI app. When I try to run the recorded test case it fails while navigating to the link.
It is unable to find the control or naviga to other link. Please suggest any workaround for it.
Below is the stacktrace for the failure
> 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
You are setting a type combo box probably (a selection control) with a value it doesn't have.
note: many times a combo box item actual value as string differs from the displayed value.
to fix: select the item in the combo box and than check with the "spy" to see its actaul value as string (mark the combo box and check it's selected value as string property).
in the future - when you'll want to select that item you'll need to enter the correct value (that was identified).