This project is read-only.

Toggling Tree Items

Feb 6, 2012 at 2:32 AM


The application under test has a tree view that has tree nodes which are system's drives and its' folders. There are also checkboxes for each tree items in the application.

I would have to select the folder and also select the checkbox in order to complete "Select" business process.

Below is the test code:

            TreeNode tr = creatorclassic.Get<TreeNode>(SearchCriteria.ByText("My Documents"));
            UIItem tr1 = (UIItem)tr;
            ToggleableItem tr2 = new ToggleableItem(tr1);
            if (tr2 == null)
                Console.Write("tr2 is null");
            tr2.State = ToggleState.On;
            Console.Write("The oput put is " + tr2.State);

When the test runs - i can see that the checkbox is being selected but the application doesnt seem to understand that the "Select the checkbox" is complete as it is still throwing "Select a Folder"

However, when I manually execute the steps, the application reacts fine. Also, when I execute the same steps via UIAVerify - the application reacts fine.

The only issue is when I run the above White code.


I looked at the link: and also the code for ToggleableItem and used it in my test code.

Not sure if there is any issue in my usage of toggleableItem with the treenode.

Iam almost stuck at this point in my test code development. Any help would be greatly appreciated.

System Details:

Windows XP SP3

.Net Framework 3.5

White Release 0.21

Application - Win32Forms




Feb 13, 2012 at 4:00 PM

I could use some help if anyone can throw some insight into the problem that am facing right now..

Feb 14, 2012 at 9:05 AM


maybe there is an issue in the eventing inside of the application. Has the TreeNode the Focus after checking, or before. It might also be a problem in the  implementation of the automationPeer (also inside of the application).


Have you tried to set the checkbox using a key (in some cases the space bar enables the checkbox). Or have you access to the checkbox  (see UIAVerify)



Feb 14, 2012 at 6:12 PM


Thanks for the reply.

1.The treenode has the focus after checking the checkbox and i can view that the checkbox has been checked. But the application doesnt react as if the checkbox is checked.

2.I have access to the checkbox from UIAVerify. I was able to invoke the TogglePattern from the UIAVerify on the treenode and the checkbox is getting selected and the application is also recognizing that the checkbox as being checked.

The issue is when my White code runs the application isnt recognizing that the checkbox as being checked eventhough I can see it being selected.

Has anyone encountered such issue / Is there an workaround to it?

The application is a legacy one and doesnt have a dedicated developer to it.



Feb 16, 2012 at 6:23 AM

Try to get the checkbox control under the treeview item and perform a click operation. See if that fires the event.

Feb 16, 2012 at 9:54 PM

Thanks for the responses. I was able to solve the issue per Thondorin's suggestion:

Keying in SPACE bar


UIItem tr = (UIItem) creatorclassic.Get<TreeNode>(SearchCriteria.ByText("easyb"));

Lessons learnt:

Checkboxes in Treenodes can be checked/unchecked by one of the below methods.(to be tried in the same order)

1.Keying in the SPace

2.Invoking the Toggle Pattern on the Treenode - (In my case - Eventhough the checkbox was selected, the app dint recognize it)

TreeNode tr1 = creatorclassic.Get(SearchCriteria.ByText("My Documents")); 
TogglePattern pattern = tr1.AutomationElement.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern; 

Note:pattern.Current.ToggleState is Read-only

3.Using ToggleableItem impl from White (same as #2)

UIItem tr = (UIItem) creatorclassic.Get<TreeNode>(SearchCriteria.ByText("My Documents"));                
ToggleableItem tr2 = new ToggleableItem(tr);
tr2.State = ToggleState.On;