locked
Improving search performance & UIMap RRS feed

  • Question

  • Hi.

    I want to improve the search performance of my CodedUI Tests for a WinForms application.

    At first I want to know how Coded UI Tests are searching controls in applications.
    I already read allot and know that there are Search & Filter Propaties.
    But my question is how CUIT is looking for it.
    Does it search From the TopMainWindow of the application all children if they match,
    If not matching all children of them …or searching on children down to the bottom then the next,…

    I’ve read that intermediate Controls are also used for searching.
    How can I verify for a control in my UIMap what Intermediate controls it has up to the main Window by browsing the code?
    And How does it help the searching (should there be only one intermediate object to the top? or more,…)

    Also there is a Smart Search Technology. I read the following blog post:
    http://blogs.msdn.com/b/vstsqualitytools/archive/2011/07/06/improving-the-performance-of-your-coded-ui-tests.aspx
    In 3 & 4 it says smart search is slow and we should try to avoid using it.
    But there are no real hints how to change/adapt an application or the Coded UI Test for doing so.


    Friday, July 27, 2012 1:50 PM

All replies

  • During my thoughts about the searching of the UIControls,

    I’ve raised another question: When does the search take place?

    When I instantiate the control in the context? (WinButton uIMoreButton = this.UIAppRunner3Window.UIGeneralWindow.UIMoreButton;)
    Or when I interact with it. Each Time? Only first?  (Mouse.Click(uIMoreButton , new Point(35, 9)); uIMoreButton.WaitForControlExist(1500); )
     
    Sometimes when I click on a button, than doing some other actions and then acting again on the button, the CodedUI Tests don’t find the button the second time.

    http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3030821-allow-connecting-to-test-controller-using-differen <-- Vote for connecting with any user to Test Contrtoller

    Monday, July 30, 2012 2:39 PM
  • Hi Victor,

    Thank you for posting in the MSDN forum.

    While playing back a Coded UI Test, the UI Test framework performs two key steps.

    1. Search for the control

    2. Perform actions on the control

    The search properties contain name-value pairs of property names and property values that can be used to identify the control, and the Search is done based on the search properties we provide.

    To help you understand it, if possible, you could check the following documents.

    How does “Coded UI test” find a control?

    Best Practices for Coded UI Tests.

    Sometimes when I click on a button, than doing some other actions and then acting again on the button, the CodedUI Tests don’t find the button the second time.

    Do you get the error message like “The playback failed to find the control with the given search properties”? If so, you can use "Edit With Coded UI Test Builder" to see properties of your control.

    Reference:

    Unable to find search properties Silverlight Page

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, July 31, 2012 7:17 AM
    Moderator
  • While playing back a Coded UI Test, the UI Test framework performs two key steps.

    1. Search for the control

    2. Perform actions on the control


    Yes, but the question is when does it perform the search?

    The search properties contain name-value pairs of property names and property values that can be used to identify the control, and the Search is done based on the search properties we provide.

    To help you understand it, if possible, you could check the following documents.

    How does “Coded UI test” find a control?

    Best Practices for Coded UI Tests.


    Im still don'T know how to figure out what intermediate controlles are used.
    I'm heavyly use the Code generatore (recorder), so the code example doe not 'fit'
    So here is a code:

            /// <summary>
            /// AssertDirectoryContains - Use 'AssertDirectoryContainsExpectedValues' to pass parameters into this method.
            /// </summary>
            public void AssertDirectoryContains()
            {
                #region Variable Declarations
                WinList uISealockListList = this.UIAppRunnerWindow.UISealockListWindow.UISealockListList;
                #endregion
    
                // Verify that 'sealockList' list box's property 'HelpText' contains 'Value'
                StringAssert.Contains(uISealockListList.HelpText, this.AssertDirectoryContainsExpectedValues.UISealockListListHelpText);
            }
    
    
        [GeneratedCode("Coded UITest Builder", "10.0.30319.1")]
        public class UISealockListWindow : WinWindow
        {
            
            public UISealockListWindow(UITestControl searchLimitContainer) : base(searchLimitContainer)
            {
                #region Search Criteria
                this.SearchProperties[WinWindow.PropertyNames.ControlName] = "sealockList";
                this.WindowTitles.Add("AppRunner");
                #endregion
            }
            
            #region Properties
            public UISealockListList UISealockListList
            {
                get
                {
                    if ((this.mUISealockListList == null))
                    {
                        this.mUISealockListList = new UISealockListList(this);
                    }
                    return this.mUISealockListList;
                }
            }
            
            public WinList UISealockListList1
            {
                get
                {
                    if ((this.mUISealockListList1 == null))
                    {
                        this.mUISealockListList1 = new WinList(this);
                        #region Search Criteria
                        this.mUISealockListList1.SearchProperties[WinList.PropertyNames.Name] = "leftPage.sealockList";
                        this.mUISealockListList1.WindowTitles.Add("AppRunner");
                        #endregion
                    }
                    return this.mUISealockListList1;
                }
            }
            #endregion
            
            #region Fields
            private UISealockListList mUISealockListList;
            
            private WinList mUISealockListList1;
            #endregion
        }


    How do I find the coresponding parent control/search limit container

    Sometimes when I click on a button, than doing some other actions and then acting again on the button, the CodedUI Tests don’t find the button the second time.

    Do you get the error message like “The playback failed to find the control with the given search properties”? If so, you can use "Edit With Coded UI Test Builder" to see properties of your control.

    Reference:

    Unable to find search properties Silverlight Page


    The properties don't change. They are all unique and don't change
    I now think that the cached handle is not actaul any more.
    Is there a way to refresh the cache or emty the whole cache to make all following action perform a search again.


    http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3030821-allow-connecting-to-test-controller-using-differen <-- Vote for connecting with any user to Test Contrtoller



    • Edited by Victor Zn Tuesday, August 7, 2012 12:04 PM
    Wednesday, August 1, 2012 1:57 AM
  • Hi Victor,

    Glad to receive your reply.

    About the first issue, as my understanding, the coded UI test method in the CodedUI Test1.cs will call the UIMap.RecordedMethod(), then it will execute the RecordedMethod() in the UIMap.Designer.cs, then it is the variable declarations, it will search for the controls which are the variable declarations, and then it will execute some actions like the Mouse.click(). If possible, you could add a breakpoint in the RecordedMethod(), for example add it in the first line code in the Varible Declarations, then try to debug the test(right click the test in test view->debug selection), you could use the Step Into(F11) to run it after the breakpoint was hit, I think you will get more information about the question “when does it perform the search?”.

    It will be better one thread for one issue, about the other questions, it would be better if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well. Thanks for your understanding.

    Sincerely,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, August 1, 2012 8:25 AM
    Moderator
  • Hi Victor,

    Glad to receive your reply.

    About the first issue, as my understanding, the coded UI test method in the CodedUI Test1.cs will call the UIMap.RecordedMethod(), then it will execute the RecordedMethod() in the UIMap.Designer.cs, then it is the variable declarations, it will search for the controls which are the variable declarations, and then it will execute some actions like the Mouse.click(). If possible, you could add a breakpoint in the RecordedMethod(), for example add it in the first line code in the Varible Declarations, then try to debug the test(right click the test in test view->debug selection), you could use the Step Into(F11) to run it after the breakpoint was hit, I think you will get more information about the question “when does it perform the search?”.


    At the moment I can't run VS and oure Application on the same Machine depending on the HW requirements of oure application.

    When I got a new VS licence I also don't know how do I see when the search is done. I don't know where/how the Information is hold.

    It will be better one thread for one issue, about the other questions, it would be better if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well. Thanks for your understanding.


    I think this is only one problem so I think it would be better to have it here:
    Connected to the question "When is the search performed?" there is the questen: How long and where the result is cached and how can I force a update or a dispose on that data (not only on a single one).

    Also it would be nice to know how to trace back to intermediate controls of a button/control.


    http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3030821-allow-connecting-to-test-controller-using-differen <-- Vote for connecting with any user to Test Contrtoller


    • Edited by Victor Zn Thursday, August 2, 2012 9:09 PM
    Thursday, August 2, 2012 3:03 PM
  • Hi Victor,

    Glad to receive your reply.J

    Maybe I misunderstanding this issue, but if you want to know when the search properties are executed, my suggestion is that you could try to debug your coded UI test like my previous reply.

    How long and where the result is cached and how can I force a update or a dispose on that data (not only on a single one).

    I’m afraid that we couldn’t make sure how long the real time takes from starting search for a control to we get the control with the search properties.

    The search performance would depend on how optimized are the control’s search properties. Generating a good Query ID depends on various factors such as unique accessible properties, control depth etc.

    Reference:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/02/01/guidelines-on-improving-performance-of-coded-ui-test-playback.aspx

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 3, 2012 5:54 AM
    Moderator
  • Hi Victor,

    Glad to receive your reply.J

    Maybe I misunderstanding this issue, but if you want to know when the search properties are executed, my suggestion is that you could try to debug your coded UI test like my previous reply.

    Also using the debug, I still don't know when the search is performed ... How would I see that it is performed?

    Where and how the results of the search is stored?

    How long and where the result is cached and how can I force a update or a dispose on that data (not only on a single one).

    I’m afraid that we couldn’t make sure how long the real time takes from starting search for a control to we get the control with the search properties.

    OK. There was a misunderstanding.

    The question is not how much time does the searching take, but where are the results of the search stored an how (long)?
    In what format is it hold - so that the play back engine knows where to click if it is needed?
    Where is it stored (so that I can look during debug for it) ?
    And: How long is it stored / Cached there till it get dropped because it is to old / not securly actuall? (This is I think causing problems)

    The search performance would depend on how optimized are the control’s search properties. Generating a good Query ID depends on various factors such as unique accessible properties, control depth etc.

    Reference:

    http://blogs.msdn.com/b/visualstudioalm/archive/2012/02/01/guidelines-on-improving-performance-of-coded-ui-test-playback.aspx


    Ofcorse the (Name) ID is important, ours is Unique over all the Application. But I'm still unsure if the thing withe the Intermediate Controlls is used correct.
    I didn't know this blog post. So I'll read to see if there is more information I can use.

    Thanks for your replies so far.


    http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3030821-allow-connecting-to-test-controller-using-differen <-- Vote for connecting with any user to Test Contrtoller


    • Edited by Victor Zn Thursday, August 9, 2012 3:10 PM
    Thursday, August 9, 2012 3:08 PM
  • Hi Victor,

    Sorry for my reply no help, I’m afraid these questions require a more in-depth level of support. I suggest you visit the following link to see the various paid support options that are available to better meet your needs.http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    Have a nice weekend,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 10, 2012 3:26 AM
    Moderator