Ranorex

Element is not working on ListView and Edit box

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexCore
View previous topic :: View next topic  
Author Message
Nik



Joined: 29 Sep 2006
Posts: 18

PostPosted: Sat Oct 07, 2006 12:10 am    Post subject: Element is not working on ListView and Edit box
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
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Sat Oct 07, 2006 12:09 pm    Post subject:
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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexCore All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum