locked
CUIT fails - cannot find the control (radgridview cell) RRS feed

  • Question

  • Hi,

    When I ran my CUIT and did an assertion on a cell in a radgridview, I got a Test Failed error message about not being able to find the control. All the steps leading up to there are marked with a green checkmark (passed), but not the assertion on the gridview cell. Here is the output from the log:


    Test method CodedUITestMethod1 threw exception:
    The playback failed to find the control with the given search properties. Additional Details: TechnologyName: 'MSAA' ControlType: 'Row' Name: 'Row 2 Column Asset Name Value mroemtest1'
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException
    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.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
    at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, ISearchArgument searchArg, IList`1 windowTitles, Int32& timeLeft)
    at Microsoft.VisualStudio.TestTools.UITesting.SearchHelper.GetUITestControlRecursive(Boolean useCache, Boolean alwaysSearch, 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(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.GetPropertyOfType(String propertyName)
    at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.get_Name()
    at CodedUITestProject2.UIMap.AssertForTestInAssetName()
    in f:\Users\Marcie\MSandbox\GlobalLabs\LabRAT\Experimental\LabRatUI\CodedUITestProject2\UIMap.Designer.cs:line 81
    at CodedUITestProject2.CodedUITest1.CodedUITestMethod1()
    in f:\Users\Marcie\MSandbox\GlobalLabs\LabRAT\Experimental\LabRatUI\CodedUITestProject2\CodedUITest1.cs:line 31
    Error HRESULT E_FAIL has been returned from a call to a COM component.
    System.Runtime.InteropServices.COMException
    at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
    at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
    at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
    at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)

    Wednesday, May 14, 2014 8:19 PM

Answers

  • marciebryant,

    This error typically occurs when

    • Either the search properties of the control to act on are not correct (Check if the control has the same properties during playback which are recorded)
    • If the control has not yet appeared, you need to use WaitFor*** methods to make playback thread wait for the control to appear before searching and perfoming any action on it.

    Here, the issue seems to be the name property of the row. You are using search property: Name: 'Row 2 Column Asset Name Value mroemtest1' which is based on the values in the second row of the grid. It is possible that the values are populated dynamically and are not same. In such cases, It is better to go by index of the row. Instead of the name property, use RowIndex as search property in code of the control:

    RowProperty.SearchProperties.Add(WinRow.PropertyNames.RowIndex,"2");


    TejasJ.

    • Proposed as answer by Amanda Zhu Monday, May 19, 2014 1:49 AM
    • Marked as answer by Amanda Zhu Wednesday, May 21, 2014 1:23 AM
    Thursday, May 15, 2014 4:43 AM
  • Hi,

    You can do it without coding. You can add RowIndex as searchproperties or change the value of RowIndex in searchproperties of a Row control in Coded UI Test Editor. Please see ‘Modify UI action properties and their corresponding control properties’ section in this article:

    Editing Coded UI Tests Using the Coded UI Test Editor

    Hope it can help you.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, May 19, 2014 1:49 AM
    • Marked as answer by Amanda Zhu Wednesday, May 21, 2014 1:23 AM
    Friday, May 16, 2014 1:35 AM

All replies

  • marciebryant,

    This error typically occurs when

    • Either the search properties of the control to act on are not correct (Check if the control has the same properties during playback which are recorded)
    • If the control has not yet appeared, you need to use WaitFor*** methods to make playback thread wait for the control to appear before searching and perfoming any action on it.

    Here, the issue seems to be the name property of the row. You are using search property: Name: 'Row 2 Column Asset Name Value mroemtest1' which is based on the values in the second row of the grid. It is possible that the values are populated dynamically and are not same. In such cases, It is better to go by index of the row. Instead of the name property, use RowIndex as search property in code of the control:

    RowProperty.SearchProperties.Add(WinRow.PropertyNames.RowIndex,"2");


    TejasJ.

    • Proposed as answer by Amanda Zhu Monday, May 19, 2014 1:49 AM
    • Marked as answer by Amanda Zhu Wednesday, May 21, 2014 1:23 AM
    Thursday, May 15, 2014 4:43 AM
  • It is possible the values are populated dynamically; good call. However, I am not sure I understand where to insert the RowProperty.SearchProperties.Add(), since much of the code is generated from the testing tool itself. Do I add this in the UIMap, or above the method call from TestMethod1 in the CodedUITest1.cs?
    Thursday, May 15, 2014 8:09 PM
  • Hi,

    You can do it without coding. You can add RowIndex as searchproperties or change the value of RowIndex in searchproperties of a Row control in Coded UI Test Editor. Please see ‘Modify UI action properties and their corresponding control properties’ section in this article:

    Editing Coded UI Tests Using the Coded UI Test Editor

    Hope it can help you.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, May 19, 2014 1:49 AM
    • Marked as answer by Amanda Zhu Wednesday, May 21, 2014 1:23 AM
    Friday, May 16, 2014 1:35 AM