As shown in, in Windows Explorer, the left sidebar is a wintree, and each node is an independent wintreeitem, such as system (C :), CDE, Dell, and so on.
It seems that CDE, Dell Is the child node of system (C :). However, when we use the coded UI test builder to traverse its hierarchy, we find that they are not a parent-child relationship, but a sibling relationship. That is to say, after obtaining the wintreeitem System (C :), call its getchildren () method, and the number of child nodes is empty.
However, if we call its nodes attribute, we can obtain the set of Child Nodes Displayed by it.
CodeExample:
wintreeitem driverc = new wintreeitem (winexplorer ); <br/> driverc. searchproperties. add ("name", "system (C :)"); </P> <p> uitestcontrolcollection nodes = driverc. nodes; </P> <p> foreach (uitestcontrol node in nodes) <br/>{< br/> wintreeitem item = node as wintreeitem; <br/> If (item! = NULL) <br/>{< br/> item. expand = true; <br/> If (item. name = "CDE") <br/>{< br/> mouse. click (item); <br/> break; <br/>}