ListView and TreeView Controls

These methods use Windows Automation operate on Automation Elements with the property ControlType.List or ControlType.TreeItem. They may behave differently to similar methods on the WinDriver Control object, which only operate on SysTreeView32 and SysListView32 window classes

ListView

Method Description

GetListItemCount

Return the number of items in the List

GetListItemLocation

Return the location coordinates of the item with the given index number or name

TreeView

Method Description

GetTreeViewItemCount

Return the number of visible items in the Tree

GetTreeItemLocation

Return the location coordinates of the item with the given name

GetTreeItemRectange

Return the rectangle enclosing the item

ExpandTreeItem

Return the location of the item

SelectTreeItem

Set the item to the selected state

GetTreeItemText

Get the text of the item for the given index number

Example

AutomationControl runWindow = FindTopAutomationWindow("Two ListBox DragDrop Demo");

IList<AutomationControl> lists = runWindow.FindControls(ControlType.List); //finds all list controls by control type

runWindow.ToControl().ShowWindow(); //makes sure that window is visible

runWindow.SetForegroundWindow(); //makes sure that window is in foreground and active

foreach (AutomationControl list in lists) //gets the number of items each list holding

{

int n = list.GetListItemCount();

WriteMessage("List items:"+n);

}

 

AutomationControl window = FindTopAutomationWindow("Demo App (multiple selection treeview");

window.ToControl().ShowWindow(ShowWindowCodes.SW_MAXIMIZE); //maximizes window if minimized

window.SetForegroundWindow();

AutomationControl tree = window.FindControl(ControlType.Tree); //gets tree control

tree.ExpandTreeItem(tree.GetTreeItemText(0)); //expands tree

Point p = tree.GetTreeItemLocation(tree.GetTreeItemText(0)); //close tree. This method can be used for both, to expand and to close

Mouse.DoubleLeftClick(p);

 

This topic was last updated on January 13, 2022, at 02:42:23 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant