none
Check boxes not working in automation

    Question

  • I am new to VS, only two weeks working with it.  I am a QA analyst, not a developer, though I am reasonably good at following code and at debugging using an IDE.

    Using VS 2012 Premium I have created a Coded UI Test to test a native C# application produced by our developers.  The application works fine manually, but when it is run in automation there are some check boxes that are not working at all.

    The generated high-level code looks like:

    this.UIMap.TestHideDvdPlayer();
    this.UIMap.AssertDvdPlayerCheckbox1NotChecked();

    When I run the test, the assert fails and in the AUT I can see that the check box is not checked and its associated action in the AUT has not occurred.  Then of course the subsequent Assertion fails and the test fails.

    When I set a breakpoint on the Assertion, I can again see that even though I have clearly executed the click of the check box (the TestHideDvdPlayer method) the check box is not checked and its associated action in the AUT has not occurred.

    I even inserted a wait for 5 seconds before the Assertion, and it still fails, so it is not a simple timing issue.

    I would appreciate if someone could tell me what I'm doing wrong, or if this is a bug in the AUT, or in VS?

    Thanks.

    Friday, September 20, 2013 3:07 PM

All replies

  • Can you post the Test Failed results/message you're getting?
    Friday, September 20, 2013 3:50 PM
  • The failure reads:

    Test Name: TestSmokeTest
    Test FullName: CORIOmaster_2._1_Smoke_Test.SmokeTest.TestSmokeTest
    Test Source: c:\Users\lmenard\SourceTree\coriomaster\C3\CORIOmaster\CORIOmaster 2.1 Smoke Test\CORIOmaster 2.1 Smoke Test\SmokeTest.cs : line 27
    Test Outcome: Failed
    Test Duration: 0:00:17.0349249

    Result Message: Assert.AreEqual failed. Expected:<False>. Actual:<True>. DVD Player checkbox 1 is checked
    Result StackTrace: 
    at CORIOmaster_2._1_Smoke_Test.UIMap.AssertDvdPlayerCheckbox1NotChecked() in c:\Users\lmenard\SourceTree\coriomaster\C3\CORIOmaster\CORIOmaster 2.1 Smoke Test\CORIOmaster 2.1 Smoke Test\UIMap.Designer.cs:line 842
       at CORIOmaster_2._1_Smoke_Test.SmokeTest.TestSmokeTest() in c:\Users\lmenard\SourceTree\coriomaster\C3\CORIOmaster\CORIOmaster 2.1 Smoke Test\CORIOmaster 2.1 Smoke Test\SmokeTest.cs:line 78

    Friday, September 20, 2013 4:05 PM
  • Hi,

    The error you posted is the Assert failure happening after the clicking of the checkbox.

    Would be good if you can send some more details on the logs to check whether the checkbox has been clicked or not.

    BTW, do you see any statement like "PlaybackSettings.ContinueOnError=true" before clicking on the checkbox. If yes then even if CodedUI does not find the checkbox test will not fail at the moment and continues to next statement.

    So, in the test log, verify if you find any information that the checkbox is not found or anything to related to checkbox.

    Observe the code to click checkbox to ensure that code is fine (sometimes while recording, we might check and un-check the checkbox by mistake)

    Regards,


    Praveen

    Friday, September 20, 2013 5:16 PM
  • Your assertion is checking to verify that the checkbox is unchecked - it's seeing that it's checked and it's failing.

    Assert.AreEqual failed. Expected:<False>. Actual:<True>

    From your post it looks like you're expecting it to be checked off - am I correct? If that's right you'll need to re-record your assertion against the checkbox while it's checked. Then it'll be "expecting" it to be True, i.e. checked. 

    Forgive me if I'm misunderstanding what your issue is.

    Friday, September 20, 2013 5:30 PM
  • Hi Praveen.

    I didn't even know it was possible to take traces.  (Like I said, I'm new to VS.)  :-)

    I've now set the trace to '4', and verified that everything is running fine up until the assertion failure.  Everything before the assertion failure completes successfully (green check marks).

    All the code is generated by VS, I have not manually coded anything.  There is no ContinueOnError.

    Thanks.

    Friday, September 20, 2013 5:44 PM
  • A bit more info, but I'm not sure if it is related to this problem.

    Before the checkbox is clicked on, I do have an Assertion that successfully verifies that it is checked.  So the second Assertion is (supposed) to verify that the check box is now unchecked.

    this.UIMap.AssertDvdPlayerCheckbox1Checked();
    this.UIMap.TestHideDvdPlayer();
    this.UIMap.AssertDvdPlayerCheckbox1NotChecked();

    Here are the three "UI Actions" editor entries for those actions:

    AssertDvdPlayerCheckbox1Checked

       - Verify that the 'Checked' property of first check box next to 'Sources' label equals 'True'

    TestHideDvdPlayer

       - Clear first check box next to '+' button

    AssertDvdPlayerCheckbox1NotChecked

       - Verify that the 'Checked' property of first check box next to '+' button equals 'False'

    Note that it is referring to the check box initially as "next to 'Sources' label" and then suddenly as "next to '+' button".  I guarantee you that the exact same UI element was used to generate all three steps.

    I have tried to "Locate the UI Control", but that fails to find it:

    The control cannot be located. The playback failed to find the control
    with the given search properties. Additional Details:
    TechnologyName:  'UIA'
    ControlType:  'CheckBox'
    Search may have failed at 'Results Summary List' List as it may have
    virtualized children. If the control being searched is descendant of
    'Results Summary List' List then including it as the parent container
    may solve the problem.

    I don't understand what 'virtualized children' are.

    In fact, 'Locate the UI Control' doesn't seem to work for any of the UI controls in my AUT.

    Friday, September 20, 2013 6:44 PM
  • Hello,

    In order to avoid the corrupted operation and project, please restart you PC, run VS as Admin, create a new coded UI test project and then record the following actions in order:

    1. Open coded UI test builder, Click the check box next to '+' button
    2. Drag the crosshair on the check box and add assertion for the property to verify if it is checked and then generate code.
    3. Please make sure the check box is still checked. Then open the coded UI test builder, uncheck it and drag the crosshair on the checkbox to add assertion for it to verify if it is unchecked.

    Then please run the coded UI test to check the result.

    While automating WPF controls in Coded UI Test, the playback would sometimes through an exception with the following error message:

    “Search may have failed at <ControlX> as it may have virtualized children. If the control being searched is descendant of <ControlX> then including it as the parent container may solve the problem.”

    Please refer to this blog to resolve it: Decoding the Coded UI Test playback failure - "Search may have failed at ControlX as it may have virtualized children ..."

    Thanks,


    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 23, 2013 8:50 AM
    Moderator
  • Hi LuFaMa.

    1) The checkbox is checked when the UI is first launched.  I have an Assertion that successfully verifies this.

    2) Then the automation clicks on that checkbox (which should uncheck it).

    3) Then I have an Assertion that tries to verify that the checkbox is unchecked.  This Assertion is actually reporting that it is still checked.

    Thanks.

    Monday, September 23, 2013 12:36 PM
  • Hi Amanda.

    I've created a brand new project and am still getting the same problem.  What it does is:

    1) Launch the application

    2) Click on a link to go to a specific screen in the application

    3) Assert that the checkbox on that screen is checked (successful)

    4) Click on that checkbox (uncheck it)

    5) Assert that the checkbox is now unchecked (this is failing, it says the checkbox is checked).

    When I watch it while the automation playback is running, I can visually verify that the checkbox is not being unchecked by the playback.

    At least in the UI Actions pane at least all of the actions and assertions are now referring to the control consistently as "first check box next to 'plus' button", but I am still unable to do a 'locate' on them.

    Here is the complete level 4 trace:

    Test Name: CodedUITestMethod1
    Test Outcome: Failed
    Result Message: Assert.AreEqual failed. Expected:<False>. Actual:<True>. Checkbox is checked
    Result StandardOutput: 
    Debug Trace:
    V, 9636, 14, 2013/09/23, 08:56:49.160, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.BeforeTestInitialize()
    V, 9636, 14, 2013/09/23, 08:56:49.248, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE.XmlSerializers
    V, 9636, 14, 2013/09/23, 08:56:49.566, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.AfterTestInitialize()
    V, 9636, 14, 2013/09/23, 08:56:49.569, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.CreateTestMethodInvoker()
    V, 9636, 14, 2013/09/23, 08:56:49.569, NEST\QTAgent32.exe, CodedUITest : CodedUITestInvoker()
    V, 9636, 14, 2013/09/23, 08:56:49.571, NEST\QTAgent32.exe, CodedUITest : CodedUITestInvoker.Invoke()
    V, 9636, 14, 2013/09/23, 08:56:56.298, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.BeforeTestCleanup()
    V, 9636, 14, 2013/09/23, 08:56:56.299, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.AfterTestCleanup()

    As for the blog article you pointed me to, I'm trying to follow that.

    According to the UI Control Map pane, the path to the checkbox is:

    - UIMap

       - UIWpfWindow

          - UIItemCustom

             - UIItemCustom1

                - UIItemButton

                   - UIItemCheckBox

    So what do I need to manually add to my code to see if this is the problem?

    Thanks.

    Monday, September 23, 2013 1:16 PM
  • I tried adding this to both the click and the assert after the click, but it still fails the same way... the click does not seem to be unchecking the checkbox (even visually I can see that) and the assert still fails (thinks the checkbox is still checked).

    uIItemCheckBox.Container = this.UIWpfWindow.UIItemCustom.UIItemCustom1.UIItemButton;
    Monday, September 23, 2013 2:33 PM
  • Hello,

    It seems your issue is that you uncheck the checkbox but Coded UI still recognizes it as checked. Please check your generated code to make sure you have the step: ‘uncheck the checkbox’ recorded.

    You said that the checkbox is checked when the UI is first launched. I doubt that if the checkbox is always checked by default even though you uncheck it. Please check your code on the checkbox to see if it will be always checked by default. I suggest that you launch the UI and uncheck the checkbox and then start to record actions for a new coded UI test to add assertion for the unchecked box to see the result.

    You said you can’t locate the control. How do you locate it? Can’t you locate the checkbox and the ‘plus’ button when you play back test? Please provide us more information.

    Since it is hard for us to repro this issue, maybe you could share us a simple application which can repro your issue, we try to Coded UI test against it in our PC. Please attach your Visual Studio Coded UI test project and app, you can upload them to the SkyDrive, and then share the download link in your post. Thanks for your understanding.

    Thanks,


    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.

    Tuesday, September 24, 2013 2:28 AM
    Moderator
  • Hi Amanda.

    The generated code for unchecking the check box is this:

            public void ActionUncheckCheckbox()
            {            #region Variable Declarations
                WpfCheckBox uIItemCheckBox = this.UIWpfWindow.UIItemCustom.UIItemCustom1.UIItemButton.UIItemCheckBox;
                #endregion
    
                // Clear first check box next to '+' button
                uIItemCheckBox.Checked = this.ActionUncheckCheckboxParams.UIItemCheckBoxChecked;
            }

        public class ActionUncheckCheckboxParams
        {
            #region Fields
            /// <summary>
            /// Clear first check box next to '+' button
            /// </summary>
            public bool UIItemCheckBoxChecked = false;
            #endregion
        }

    As I said in the original post, I am not the developer, just QA, so I cannot check the source of the UAT. However I guarantee you that the checkbox is checked by default... when I run the scenario manually it works fine.

    When I say I cannot 'locate' the control I do not mean visually. What I mean is this:

    1) Manually launch the application

    2) Go into VS "UI Actions" by double-clicking "UIMap.uitest".

    3) Expand the "AssertCheckboxIsUnchecked" twisty.

    4) Click on the step description "Verify that the 'Checked' property of first check box next to '+' button equals 'False'.

    5) In the "UI Control Map" pane, the control for that step is highlighted.

    6) Right-click on that control in the "UI Control Map" and select "Locate the UI Control".  This fails with that message "Search may have failed at 'Results Summary List' List as it may have
    virtualized children. If the control being searched is descendant of 'Results Summary List' List then including it as the parent container may solve the problem.".

    (I don't know if that 'Locate' failure is related to my original problem or not, it is just an error that I am getting during investigation.)

    If VS couldn't find the '+' button or the checkbox at playback time, I would expect it to throw an exception saying so.  But it does not throw any such error, even in the level 5 trace I'm taking.  In fact, if I watch the UAT during playback I can see it position the mouse pointer over the correct checkbox, but the action of actually clicking on it is never apparent... it remains checked, and then the subsequent Assertion fails.

    (FYI... When that checkbox is manually unchecked it also triggers changes to a different part of the app.  In playback those changes also never happen.)

    So VS is finding the checkbox during playback, but is not clicking on it.

    I can't give you our current app as it is an unannounced product.  I will ask our developers if they can put together a simple app that demonstrates this, but I don't know if they will have time to.  For now, all we have to work with is what I can provide you with descriptively, so I'm trying to be as clear and detailed as possible.

    Thanks.

    Tuesday, September 24, 2013 12:55 PM
  • Hello,

    Please refer to this article: Analyzing Coded UI Tests Using Coded UI Test Logs to collect Coded UI test log to analyze the test running.

    Even though the virtualized issue does not occur during playback, I still suggest you to try the suggestions provided in the blog: Decoding the Coded UI Test playback failure - "Search may have failed at ControlX as it may have virtualized children ..." at the “+” button and the checkbox to check the result.

    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 25, 2013 2:50 AM
    Moderator
  • Hi Amanda.

    I have already done both of these things.  Please see my posts from:

    - Monday, September 23, 2013 1:16 PM and

    - Monday, September 23, 2013 2:33 PM.

    Thanks.

    Wednesday, September 25, 2013 12:03 PM
  • Hello,

    I don’t get some useful information from the log. In order to further look at this issue, it will be better that you provide us a simple application which can repro your issue so that we can Coded UI test it on our PC to research the issue.

    Thanks,


    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.

    Thursday, September 26, 2013 4:59 AM
    Moderator
  • Hi Amanda.

    As I said, I can't give you our actual app, and our developers are too busy developing the actual product to code up a smaller app that reproduces the problem.  I will keep requesting that, but for now it isn't possible to provide you with code.

    I have however downloaded the latest build of our product, and now the actual clicking on the checkbox is throwing an exception (if you recall, previously it was not throwing any exception even though you could visually see it was not working).

    The exception that is now being thrown by clicking on the checkbox is:

    Test Name: TestSmokeTestTest
     
    Outcome: Failed
    
    Message: Test method CORIOmaster_2._1_Smoke_Test.SmokeTest.TestSmokeTest 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:  'CheckBox'
    AutomationId:  'CheckboxDisplayVisible'
     Search may have failed at '' List as it may have virtualized children. If the control being searched is descendant of '' List 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.
    
    StandardOutput:
    
    Debug Trace:
    V, 8604, 14, 2013/09/27, 09:07:53.265, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.BeforeTestInitialize(
    V, 8604, 14, 2013/09/27, 09:07:53.365, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE.XmlSerializersV, 8604, 14, 2013/09/27, 09:07:53.662, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.AfterTestInitialize()
    V, 8604, 14, 2013/09/27, 09:07:53.665, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.CreateTestMethodInvoker()
    V, 8604, 14, 2013/09/27, 09:07:53.665, NEST\QTAgent32.exe, CodedUITest : CodedUITestInvoker()
    V, 8604, 14, 2013/09/27, 09:07:53.668, NEST\QTAgent32.exe, CodedUITest : CodedUITestInvoker.Invoke()
    V, 8604, 14, 2013/09/27, 09:08:06.198, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:08:06.205, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:08:06.208, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:08:06.255, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:08:06.259, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:08:06.262, NEST\QTAgent32.exe, CodedUITest : Assembly resolver trying to resolve Microsoft.VisualStudio.TestTools.UITest.Extension.IE64.EventHelper
    V, 8604, 14, 2013/09/27, 09:09:11.934, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.BeforeTestCleanup()
    V, 8604, 14, 2013/09/27, 09:09:11.934, NEST\QTAgent32.exe, CodedUITest : CodedUITestExtension.AfterTestCleanup()

    Now perhaps we are hitting the search path problem described in one of the articles you posted?

    In the "UI Control Map" pane in VS, the path to the check box is:

    > UIMap > UIWpfWindow > UIItemCustom > UIItemCustom11 > UICheckboxDisplayVisibCheckbox

    What do I have to edit to try this manual workaround?

    Thanks.

    Friday, September 27, 2013 1:54 PM
  • Based on my understanding of the article you pointed me to, I updated the code before clicking on the checkbox as follows:

            public void TestDisplay1Hide()         {             #region Variable Declarations             WpfCheckBox uICheckboxDisplayVisibCheckBox = this.UIWpfWindow.UIItemCustom.UIItemCustom11.UICheckboxDisplayVisibCheckBox;             #endregion this.UIWpfWindow.UIItemCustom.UIItemCustom11.UICheckboxDisplayVisibCheckBox.Container = this.UIWpfWindow.UIItemCustom.UIItemCustom11; this.UIWpfWindow.UIItemCustom.UIItemCustom11.Container = this.UIWpfWindow.UIItemCustom; this.UIWpfWindow.UIItemCustom.Container = this.UIWpfWindow;

                // Clear 'CheckboxDisplayVisible' check box             uICheckboxDisplayVisibCheckBox.Checked = this.TestDisplay1HideParams.UICheckboxDisplayVisibCheckBoxChecked;         }

    But the click on the checkbox still gets the same exception.

    Did I do something incorrectly?

    Friday, September 27, 2013 2:44 PM
  • Hello,

    Based on the error message in your previous reply,

    with the given search properties. Additional Details:
    TechnologyName:  'UIA'
    ControlType:  'CheckBox'
    Search may have failed at 'Results Summary List' List as it may have
    virtualized children. If the control being searched is descendant of 'Results Summary List' List then including it as the parent container
    may solve the problem.

    I think that problem control is 'Results Summary List' List. So please check the UI tree hierarchy of the list control to see if it has virtualized children which impact the search of the checkbox control. And then modify your code based on the blog.

    Thanks,


    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 30, 2013 2:54 AM
    Moderator
  • Amanda,

    The "Results Summary List" exception is not occurring when I run the test, it is occurring when I try to do "Locate the UI Control" in VS.  I don't believe there is anything called "Results Summary List" in our application at all.  I believe that it is the "Test Explorer" in VS itself.  I don't know why VS is looking within itself for the UI Control... the AUT is running.  But like I said, that is not the original problem.

    The original problem is that an Assert is failing because the previous clicking action on the checkbox apparently is not working.

    In my last posting I reported that the playback was now throwing an exception when it actually clicked on the checkbox (and please notice that the UI element it referenced was a blank string "").  Unfortunately though, that occurred only once... now I am back to the original behavior.

    Multiple times now I have posted the UI control tree according to the "UI Control Map" pane in VS.  Here it is again:

    UIMap -> UIWpfWindow -> UIItemCustom1 -> UICheckboxDisplays15o2CheckBox

    Notice how short it is.

    Also I mentioned previously that I can see the mouse being moved to the correct checkbox, it just never seems to execute the actual click.  Since it is moving the mouse to the correct checkbox, I am not convinced that it is a search path issue.

    I really wish I could give you a sample app, but at least for now I cannot.  I will keep trying to get one.

    Thanks.

    Monday, September 30, 2013 12:42 PM
  • If you are not come up with any solution yet, then i think you should go for descriptive programming in coded UI.

    In this first of all you need to create an object for that WpfCheckBox.

    And then add some search properties to it.

    and then Click on that WpfCheckBox. It will uncheck your WpfCheckBox.

    and at last you can put your assert statement.


    Frestest

    Tuesday, October 01, 2013 6:16 AM