locked
MenuItem slow to click in testing RRS feed

  • Question

  • When I'm trying to access menu items from the menu toolbar it takes ~20-40 seconds to find the menu item, but for other objects seems to take much less time (instantly). Any idea why that happens? The object reference was generated by VS for Coded UI testing, I modified it to the following:

    Mouse.Click(this.UIWindow1.UIApplicationMenuBar.UIWorkbenchMenuItem.UISpringbackMenuItem);

    Thanks,

    Henny.


    • Edited by HennyT Thursday, August 29, 2013 7:47 PM
    Thursday, August 29, 2013 7:46 PM

Answers

  • Hello,

    Thank you for your post.

    Which version of Visual Studio do you use? Do you generate the coded UI test through action recording using Coded UI Test Builder?

    Please refer to this blog: How To: Enable Tracing for “UI Test” Components and set EqtTraceLevel to 4 under system.diagnostics node like  the following settings in QTAgent32.exe.config

    <system.diagnostics>

        <switches>

            <!-- You must use integral values for "value".  Use 0 for off, 1 for

                 error, 2 for warn, 3 for info, and 4 for verbose. -->

            <add name="EqtTraceLevel" value="4" />

        </switches>

      </system.diagnostics>

    In this case, you will get verbose log information and can check which parts of test consume the long time. Please post related log information here so that we can further look at this issue.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by HennyT Wednesday, September 4, 2013 4:35 PM
    Friday, August 30, 2013 8:39 AM

All replies

  • Hello,

    Thank you for your post.

    Which version of Visual Studio do you use? Do you generate the coded UI test through action recording using Coded UI Test Builder?

    Please refer to this blog: How To: Enable Tracing for “UI Test” Components and set EqtTraceLevel to 4 under system.diagnostics node like  the following settings in QTAgent32.exe.config

    <system.diagnostics>

        <switches>

            <!-- You must use integral values for "value".  Use 0 for off, 1 for

                 error, 2 for warn, 3 for info, and 4 for verbose. -->

            <add name="EqtTraceLevel" value="4" />

        </switches>

      </system.diagnostics>

    In this case, you will get verbose log information and can check which parts of test consume the long time. Please post related log information here so that we can further look at this issue.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by HennyT Wednesday, September 4, 2013 4:35 PM
    Friday, August 30, 2013 8:39 AM
  • Hi Amanda,

    I am using Visual Studio 2012.

    Yes, I generate the coded UI test through action recording using Coded UI Test Builder. 

    The following warning shows:

    Click 'Project' -> 'Exit' menu item0:27.413
    The target element "Technology Name: 'MSAA';Search Configuration: 'VisibleOnly'; Search Properties - ControlType : 'MenuBar',Name : 'Application'" was not found, so all intermediate elements were ignored. As a result, an incorrect element that matches the target element's search properties can be found. Verify that all intermediate elements in Query Id have valid and unique search properties.
    Technology Name: 'MSAA'
    Search Properties - 
         ControlType : 'MenuItem'
         Name : 'Exit'
    Mouse button : 'Left'



    • Edited by HennyT Friday, August 30, 2013 1:45 PM
    Friday, August 30, 2013 12:59 PM
  • Hello,

    Please use this following code in your coded UI test method:

    Playback.PlaybackSettings.MatchExactHierarchy = true;

    If no help, please use: Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None;

    For more information, please reference:

    http://blogs.msdn.com/b/vstsqualitytools/archive/2009/08/10/configuring-playback-in-vstt-2010.aspx

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 2, 2013 1:48 AM
  • Hi Amanda,

    The two controls you suggested actually do the opposite of what I want it to do (they don't find the buttons at all). I have two further questions:

    1) Is there a way to make SmartMatch the first phase of search instead of the third?

    2) Is there a way to click the menuitem without locating the menubar first?

    3) By adding the code

    Mouse.Click(new Point(0,0));

    in front of

    Mouse.Click(this.UIFormingSuiteProject1Window.UIApplicationMenuBar.UIWorkbenchMenuItem.UISpringbackMenuItem);

    the code runs without error and seems to be able to find the item immediately. Do you know why that happens?

    Thanks,
    Henny.

    .Click(this.UIFormingSuiteProject1Window.UIApplicationMenuBar.UIWorkbenchMenuItem.UISpringbackMenuItem);

     

    Tuesday, September 3, 2013 2:37 PM
  • Hello,

    I am afraid that we can’t specify the hierarchy where the SmartMarch applies since there are only three options: Control,None and TopLevelWindow for SmartMatchOptions Enumeration.

    We can skip the menubar control to locate the menuitem control through hand coding a Coded UI test. But generally skipping a parent control above the target control may impact the coded UI test because of this issue described in this blog: Decoding the Coded UI Test playback failure - "Search may have failed at ControlX as it may have virtualized children ..." .If you want to do it, you have to make sure that the menuitem control can be found well through the hierarchy you use to search the menuitem and the searchproperties you use to find the menuitem.

    Reference:

    Hand-coding a Coded UI Test

    For question3, I am not sure about your coded UI test. Whether the mouse loses control on the application before the menuitem is clicked? As far as I know, when we create the coded UI test through action recording, there are coordinations in Mouse.Click() like this: Mouse.Click(uICloseButton, new Point(28, 18));

    Please try to create the coded UI test through action recording using Coded UI Test Builder again. Then you check the generated code in UIMap.Designer.cs file to see how the menuitem control is found hierarchy by hierarchy and what properties are used to locate the control and compare it with the previous coded UI test to check if there are any differences.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 4, 2013 5:21 AM