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
Can not read items of Listbox
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
I think this third party listbox does not support accessibility correctly, the Element Name should be the text of the ListBox item.
Jenö
Ranorex Team
Yes, you can use the Element functions, please try the following code:Is there any other way, I can try, to access this listbox?
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);
Ranorex Team
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?
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?
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
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.Is there anything else I can try?
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
- Support Team
- Site Admin
- Posts: 12167
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Graz, Austria
Please read the following blog in this case:...but we think that it is a .net application.
http://www.ranorex.com/blog/transfering ... et-control
Jenö
Ranorex Team