locked
CUIT : Click action on ListItem is not playing back RRS feed

  • Question

  • Hi,

    I am using Coded UI Test to test my application. I am currently on VSTS 2012 premium with Update 4.

    I have recorded a click action on a Cell inside the List View with CUIT. But when i am playing back the script it is not working.

    Steps Reproduce :

    1. Record click action on bottom list item of list view.
    2. Close the application and reopen and then run the script. it will fail.

    Note : In our application List View has lot of list Items. List Item on which click action is to be played is not in visible state. To make it visible we have to use scroll bar.

    I can share the sample application and CodedUI test project if required.

    Let me know for further information.


    Regards, Bhagavan.

    Tuesday, November 18, 2014 3:38 AM

Answers

  • Hi Crystal,

    Thanks for your information.

    Yes i tried from my side with spy tool and it is showing only visible children. but when i am trying "GetChildren()" API on list View it is giving all child elements. so i tried the below code, it is working fine for me.

    	/// <summary>
            /// RecordedMethod2
            /// </summary>
            public void RecordedMethod2()
            {
                #region Variable Declarations
                WpfCell uIRajendar2Cell = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable.UIRajendar21584PPMGUIADataItem.UIRajendar2Cell;
    
                if (!uIRajendar2Cell.TryFind())
                {
                    WpfControl requiredlistItem = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable.UIRajendar21584PPMGUIADataItem;
                    WpfTable list = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable;
    
                    foreach (UITestControl listitem in list.GetChildren())
                    {
                        if (listitem.Name == requiredlistItem.SearchProperties["Name"])
                        {
                            listitem.EnsureClickable();
                            break;
                        }
                    }
                }
                
                #endregion
    
                // Click 'Rajendar2' cell
                Mouse.Click(uIRajendar2Cell, new Point(44, 7));
            }

    Even though above mechanism is working for me i am very much worried about performance. it will take considerable amount of time for getting all children(at "GetChildren()") if container has too many.


    Regards, Bhagavan.

    • Marked as answer by Amanda Zhu Friday, November 28, 2014 9:30 AM
    Friday, November 21, 2014 8:39 AM

All replies

  • Hi Bhagavan,

    Note : In our application List View has lot of list Items. List Item on which click action is to be played is not in visible state. To make it visible we have to use scroll bar.

    Please make sure that the targeted cell is visible during playback testing. If you only record click action in a cell on the bottom of the list view, please scroll the list view to the bottom to make sure the cell is visible before you start running the test.

    Also you can include these actions in your recording actions: opening the application, go to the list view, scroll the list view to get the targeted cell, then the scroll action will be played back and the cell will be visible during playback.

    If I misunderstood you, please explain it and share us with you sample app and coded UI test project.

    Thanks,


    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.


    • Edited by Amanda Zhu Wednesday, November 19, 2014 3:23 AM edit
    Tuesday, November 18, 2014 8:00 AM
  • Hi,

    Thanks for the quick reply.

    If i include moving scroll bar actions in my recorded steps. it will give inconsistent result because the list item which is to be selected may not be the last item every time. so i don't know how many times scroll has to be done. we need a robust solution for this.

    I will send sample application and coded UI test project to mentioned mail.


    Regards, Bhagavan.

    Tuesday, November 18, 2014 9:23 AM
  • Hi Bhagavan,

    Your application under test is opened with non-maximized size by default. Please including this action: maximize the application in your recording and then click expected cell.

    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.

    Wednesday, November 19, 2014 3:33 AM
  • Hi Crystal,

    I have created a sample application with list to reproduce the problem. But in my application this list will be of fixed size irrespective of application mode(minimized or maximized).

    Could you please provide robust solution instead of workarounds.


    Regards, Bhagavan.

    Wednesday, November 19, 2014 4:36 AM
  • Hi Bhaganvan,

    For your application, not all the list items within the list view is shown and visible when you open the application. If you want to test the ‘hidden’ list item, then you must make sure it is visible during playback.

    The solution I can think of to make the list item visible is:

    1. maximize the application in your coded UI test
    2. make all list items shown and visible with the list view when the non-maximized application window opens.

    Thanks,


    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.

    Wednesday, November 19, 2014 8:30 AM
  • Hi Crystal,

    There is a small observation if we select the required list item after invoking application and make it invisible by using scroll bar. In this case script is able to click on list item(automatically it is moving to visible state).

    As you mentioned above if the problem is regarding the visibility of list items, script should fail for all cases. but it is working for above case(when the required item is selected).

    Even i am able to get all list items of list irrespective of size of the list and visibility of list items.

    Is there any problem regarding the searching mechanism from CUIT?


    Regards, Bhagavan.

    Wednesday, November 19, 2014 10:00 AM
  • Hi Bhagavan,

    if we select the required list item after invoking application and make it invisible by using scroll bar. In this case script is able to click on list item(automatically it is moving to visible state).

    The scrolling action is performed automatically during playback, which causes the target control to be visible.

    Through recording other cells, I found that Coded UI uses the same properties as the search properties like ColumnHeader,FrameworkId and ControlType to locate all cells by default. Please add Name property as search properties in Coded UI Test Editor to search the control. Please see ‘Modify UI action properties and their corresponding control properties’ section in this thread: Editing Coded UI Tests Using the Coded UI Test Editor

    Thanks,


    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.

    Thursday, November 20, 2014 2:47 AM
  • Hi Crystal,

    Thanks for the reply.

    when we are tying to playback the script, it is getting failed and result message shown as below:

    Result Message:	
    Test method ClickOnDataItemTest.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'
    ControlType:  'DataItem'
    Name:  'Rajendar21584PPMGUI-ATPsHyderabad'
     Search may have failed at 'CustomList' Table as it may have virtualized children. If the control being searched is descendant of 'CustomList' Table then including it as the parent container may solve the problem. ---> 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.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)
     --- 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.FindFirstDescendant(String queryId, Int32 maxDepth, Int32& timeLeft)
    It is failing to find the data item which is already having Name as search property.



    Regards, Bhagavan.

    Thursday, November 20, 2014 4:57 AM
  • Hi Bhagavan,

    I also got this issue sometimes randomly and sometimes always. But if I maximize the application window, this issue won’t occur. Please try it.

    Generally we resolve that error based on the workaround provided in this blog: Decoding the Coded UI Test playback failure - "Search may have failed at ControlX as it may have virtualized children ..." I tried Inspect.exe located in %Program Files (x86)%\Windows Kits\8.1\bin\x64 or else place on your machine: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318521%28v=vs.85%29.aspx to check the control UI and don’t find one control has virtualized children. You can try it on your side.

    Thanks,


    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.

    Thursday, November 20, 2014 6:17 AM
  • Hi Crystal,

    Thanks for your information.

    Yes i tried from my side with spy tool and it is showing only visible children. but when i am trying "GetChildren()" API on list View it is giving all child elements. so i tried the below code, it is working fine for me.

    	/// <summary>
            /// RecordedMethod2
            /// </summary>
            public void RecordedMethod2()
            {
                #region Variable Declarations
                WpfCell uIRajendar2Cell = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable.UIRajendar21584PPMGUIADataItem.UIRajendar2Cell;
    
                if (!uIRajendar2Cell.TryFind())
                {
                    WpfControl requiredlistItem = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable.UIRajendar21584PPMGUIADataItem;
                    WpfTable list = this.UISampleWPFApplicationWindow.UISampleWPFAppTabContrTabList.UICustomListViewTabTabPage.UICustomListTable;
    
                    foreach (UITestControl listitem in list.GetChildren())
                    {
                        if (listitem.Name == requiredlistItem.SearchProperties["Name"])
                        {
                            listitem.EnsureClickable();
                            break;
                        }
                    }
                }
                
                #endregion
    
                // Click 'Rajendar2' cell
                Mouse.Click(uIRajendar2Cell, new Point(44, 7));
            }

    Even though above mechanism is working for me i am very much worried about performance. it will take considerable amount of time for getting all children(at "GetChildren()") if container has too many.


    Regards, Bhagavan.

    • Marked as answer by Amanda Zhu Friday, November 28, 2014 9:30 AM
    Friday, November 21, 2014 8:39 AM
  • Hi,

    Your way is feasible but maybe it has performance issues. Currently I don’t have other good solutions for your issue.

    Based on my experience with your sample project, you can move scroll bar to the expected position in your recorded actions to avoid this issue. You don’t need to know how many times scroll has to be done. You create the coded UI test using Coded UI Test Editor instead of hand coding, Coded UI will perform the scroll action automatically during playback.

    Another way to avoid your issue is to maximize the application window, but you don't want it. I think this way not only can resolve this issue but also it doesn't affect test performance.

    Thanks,


    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.

    Friday, November 21, 2014 9:03 AM