Hi,
The element approach of selecting item one at a time is not working on ListView and Edit. Are there any known issues or it is not supported.
I am using the same code you suggested for navigating in the Listbox.
The code is failing when I use
if ( RxElementFindChild(&element, ROLE_SYSTEM_OUTLINE, NULL, NULL, &editBoxElement) == TRUE )
Please suggest.
I also want to know the way to retrieve the items which are selected in a ListView. For e.g. I have a listview having 10 items. Out of which item 2,5,7 are selected(highlighted). How can I know using Ranorex API that items 2,5,7 are selected.
Thanks.
Nikhil
Element is not working on ListView and Edit box
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:
Dump out and select all list items in a list view:
Get the selection flag of the list view items:
Jenö Herget
Ranorex Team
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: Select all
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);
}
Code: Select all
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);
}
}
}
Code: Select all
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);
}
}
}
Ranorex Team