This project is read-only.

Object Hierarchy in CUITe

Aug 20, 2012 at 7:11 PM

I have two objects in my winforms application that have the same name.  The are both named close.  One is a child of the main window and the other is a child of a child window.  It looks like this:

Main Window - Close

Main Window - Child Window - Close.

Is there anyway in CUITe I can use the object hierarchy so I click the second close and not the first?  Has anyone run into a situation like this?  How did you handle it?





Aug 21, 2012 at 10:27 AM

Hi Jeff,

It should be fine.

Have you tried using the coded ui test recorder built into visual studio to see what it outputs?

Aug 21, 2012 at 3:40 PM

Thanks for the reply.

I haven't.  How would I use the output of that in the CUITe Object Repository? 

When you say "It should be fine" do you mean that there is a way in CUITe to distinguish between two objects that are named the same thing?

Aug 21, 2012 at 4:11 PM

I made a recording of the click on the stop button and this is what I got:



        public WinButton UICloseButton
                if ((this.mUICloseButton == null))
                    this.mUICloseButton = new WinButton(this);
                    #region Search Criteria
                    this.mUICloseButton.SearchProperties[WinButton.PropertyNames.Name] = "Close";
                return this.mUICloseButton;
I'm trying to figure out how to integrate this into the CUITe Object Repository

Aug 21, 2012 at 10:41 PM

Hi Jeff,

The CUITe FAQ explains the differences between CUIT and CUITe and how CUITe enhances working with CUIT. Asked Questions

So basically as long as your search criteria makes a distinction between your objects, CUIT should match each one accordingly.

For example, the close button on the window with the title "MyHighLevelContainer" will be found differently than a close button on a window with a different title.

Aug 22, 2012 at 3:43 PM


Thanks for the reply.

My problem is that all of the attributes of the control are the same.  The only difference is that one is contained by the top level window and the other is contained by a window that is a child of the top level window.

Is there a way to set the search criteria based on the attributes of the immediate parent?  If so, can you show me an example?




Aug 24, 2012 at 9:20 AM
Edited Aug 24, 2012 at 9:21 AM

Hi Jeff,

I have not personally experienced this problem as I've always had control of the window attributes of the application under test so I was able to ensure that every window and control had unique attributes.

If that is not an option for you, you may try to change some of the default coded ui playback settings as described here:

Configuring Playback in VSTT 2010


Playback.PlaybackSettings.MatchExactHierarchy = true;
Playback.PlaybackSettings.SmartMatchOptions = SmartMatchOptions.None;