locked
Automating Three State (Tri-State) CheckBox with Coded UI RRS feed

  • Question

  • Hi,

    I have an application that requires a three state (tri-state) checkbox within a treeview. As you know this isn't supported so most of the solutions is to draw the checkbox image.

    When this happens, Coded UI detects the control as a treeview and treeviewitems instead of checkboxtreeviewitems. Because of this there is no way for me to not only determine the state of the check box (checked, not checked, indeterminate) but I also can't check the box!

    My developer has giving me an ability via the keyboard to toggle the state so that I can uncheck or check a checkbox, but I still need to figure out what the actual state is, so I know whether I need to check the box or not.

    Is there any way for my developer to push that information to me, and if so, what is the best method, using an existing property or creating a custom property that I can get (if that is possible).

    Thanks

    Monday, September 30, 2013 7:59 PM

Answers

  • Hello,

    You can try to custom a property which display whether the checkbox is checked for the control and then write your own extension to make Coded UI recognize the custom property.

    For more information, please see: Enable Coded UI Testing of Your Controls

    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.

    • Marked as answer by Amanda Zhu Monday, October 7, 2013 8:09 AM
    Wednesday, October 2, 2013 3:10 AM

All replies

  • Hello,

    Thank you for your post.

    If your developer custom-draw the TreeView control for each checkbox to accomplish three state checkbox in a treeview, I think that it is expected that Coded UI recognizes the control as a treeview and treeviewitems instead of checkboxtreeviewitems.

    Please see this thread: http://social.msdn.microsoft.com/Forums/en-US/a4071304-c529-4f8f-bc58-ede0bd814fde/threestate-checkbox-in-treeview

    “Is there any way for my developer to push that information to me”

    I don’t think this issue is a test issue. You should discuss with your developer to get a way. Or you can consult on some development forum based on the type of application to check if there are any ways to toggle the status of checkbox through the keyboard programmatically.

    “what is the best method, using an existing property or creating a custom property that I can get”

    Do you mean that you want to use existing property to determine the status of the checkbox in Coded UI test? If yes, you can check if there is a property which expose the state of checkbox. For example WpfTreeItem in Coded UI has State and Selected property. In this case you can use it in your coded UI test.

    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.

    Tuesday, October 1, 2013 9:11 AM
  • Hi,

    “Is there any way for my developer to push that information to me”

    I don’t think this issue is a test issue. You should discuss with your developer to get a way. Or you can consult on some development forum based on the type of application to check if there are any ways to toggle the status of checkbox through the keyboard programmatically.

    This is not about toggling status of the checkbox through keyboard programmatically, but about being able to get the status in Coded UI. Because it is not a real checkbox, none of the properties display any information to tell me whether it is checked or not checked. For example, State only says "expanded, focusable, selectable". I'm trying to figure out what my developer can do to modify an existing property such as state to ensure that information is passed, or be able to use GetProperty(string name) to get a custom property value.

    “what is the best method, using an existing property or creating a custom property that I can get”

    Do you mean that you want to use existing property to determine the status of the checkbox in Coded UI test? If yes, you can check if there is a property which expose the state of checkbox. For example WpfTreeItem in Coded UI has State and Selected property. In this case you can use it in your coded UI test.

    Per above, state property doesn't display anything about the checkbox, is there a way for the developer to modify this property so it contains that kind of information?

    Tuesday, October 1, 2013 2:36 PM
  • Hello,

    You can try to custom a property which display whether the checkbox is checked for the control and then write your own extension to make Coded UI recognize the custom property.

    For more information, please see: Enable Coded UI Testing of Your Controls

    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.

    • Marked as answer by Amanda Zhu Monday, October 7, 2013 8:09 AM
    Wednesday, October 2, 2013 3:10 AM