You should use ROLE_SYSTEM_LIST for the list view and ROLE_SYSTEM_LISTITEM for the items (see RanorexSpy).
Here are some C++ code samples:
(Tested with VS2005Application.exe)
Find and select a list item with the name Test2 in a list view:
Code: click into code to enlarge
ElementStruct listItem;
BOOL bRet = RxElementFindChild(&element, ROLE_SYSTEM_LISTITEM, "Test2", NULL, &listItem);
if (bRet==TRUE)
{
printf(" List item found\n");
RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(500);
}
Dump out and select all list items in a list view:
Code: click into code to enlarge
ElementStruct listElement;
if ( RxElementFindChild(&element, ROLE_SYSTEM_LIST, NULL, NULL, &listElement) == TRUE )
{
int childCount = RxElementGetChildCount(&listElement);
for(int i=0; i< childCount; i++)
{
if ( RxElementGetChild(&listElement, i, &listItem) == TRUE )
{
printf(" Item(%d)=%s\n",i,listItem.Name);
RxElementSelect(&listItem, SELFLAG_TAKEFOCUS | SELFLAG_TAKESELECTION);
RxSleep(300);
}
}
}
Get the selection flag of the list view items:
Code: click into code to enlarge
ElementStruct listElement;
if ( RxElementFindChild(&element, ROLE_SYSTEM_LIST, NULL, NULL, &listElement) == TRUE )
{
int childCount = RxElementGetChildCount(&listElement);
for(int i=0; i< childCount; i++)
{
if ( RxElementGetChild(&listElement, i, &listItem) == TRUE )
{
int state = RxElementGetState(&listItem);
if( state & STATE_SYSTEM_SELECTED)
printf(" Item(%d)=%s selected\n",i,listItem.Name);
else
printf(" Item(%d)=%s not selected\n",i,listItem.Name);
RxSleep(300);
}
}
}
Jenö Herget
Ranorex Team |