Can not read items of Listbox

Class library usage, coding and language questions.
abalone
Posts: 3
Joined: Tue Oct 21, 2008 8:03 am

Can not read items of Listbox

Post by abalone » Tue Oct 21, 2008 8:42 am

Hi,

I'm running RanorexPython on Python 2.3 and automating a third party application. This application has a listbox in a seperate window.

When looking with the RanorexSpy on this Listbox then i get following information (which is the same for all list items):
Control Handle: 0x950AC0
Control Caption/text: empty
Control Class name: ListBox #1
Control name: empty
Control Id: 1047

Element Role: ListItem (34)
Element Name: empty
Element Class: ListBox
Value: empty

Which means that the Spy does not show any text inside of the listbox.

I tried to access this listbox by using:
.) RanorexPython.ControlGetText(listbox_handle) -> which returns me "None"
.) RanorexPython.ListBoxGetItemCount(listbox_handle) -> returns me the correct item count of the list box
.) RanorexPython.ListBoxGetItemText(listbox_handle, index) -> returns me for all list box items an empty string
.) RanorexPython.ListBoxSetSelectedIndex(listbox_handle, index) and requesting the index by:
RanorexPython.ListBoxGetSelectedIndex(listbox_handle) -> returns me always index 0

None of the Listbox methods except GetItemCount is working for this listbox and I can not read the text within the listbox.

Is there any other way, I can try, to access this listbox?

Regards,
abalone

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Oct 21, 2008 10:32 am

I think this third party listbox does not support accessibility correctly, the Element Name should be the text of the ListBox item.
Is there any other way, I can try, to access this listbox?
Yes, you can use the Element functions, please try the following code:

Code: Select all

print '---------------------------------------------------------------------'
print '   searching the ListBox by ControlName'
print '---------------------------------------------------------------------'
listBox=Ranorex.FormFindChildControlName(form,'listBox1')
if listBox == 0:
    print 'ERROR: listBox not found'
    return 1        
print '      listBox=' + hex(listBox)

print '      moving the mouse to the control'
Ranorex.MouseMoveToControl(listBox)
element = Ranorex.ControlGetElement(listBox)


itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_LISTITEM)
print '      item count =' + str(itemCount)

for index in range(0,itemCount):
    child= Ranorex.ElementGetChildFieldItem(index)
    if child == None:
        print 'Cannot read child' + str(index)
        continue;
    print '      select the child ' + str(index)
    Ranorex.ElementSelect(child, Ranorex.SELFLAG_TAKEFOCUS | Ranorex.SELFLAG_TAKESELECTION);
Jenö
Ranorex Team

abalone
Posts: 3
Joined: Tue Oct 21, 2008 8:03 am

Post by abalone » Wed Oct 22, 2008 11:57 am

Thank you for your fast response.

I tried your proposed code and the list elements are correctly selected at the application. But unfortunately i still get an empty string for all the child elements of this listbox if i want to read it with
.) RanorexPython.ElementGetValue(child)
or
.) RanorexPython.ElementGetName(child)
or
.) RanorexPython.ListBoxGetSelectedText(listBox)

Is there anything else I can try?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Wed Oct 22, 2008 1:48 pm

Is there anything else I can try?
It depends on the underlying technology, if the application under test is a .NET application, then you can call functions or get/set the properties of the controls. If the application will be developed in your company, your developer can set the AccessibleName property of the ListView items.

Older Win32 or MFC applications can be automated with windows messages, in this case you need additional information from developer.

What kind of application do you want to test?

Jenö
Ranorex Team

abalone
Posts: 3
Joined: Tue Oct 21, 2008 8:03 am

Post by abalone » Thu Oct 23, 2008 9:06 am

The application is not developed in our company so we do not have any detailed information about the used technology but we think that it is a .net application.

best regards,
abalone

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Oct 23, 2008 10:02 am

...but we think that it is a .net application.
Please read the following blog in this case:

http://www.ranorex.com/blog/transfering ... et-control

Jenö
Ranorex Team