Cannot read items in a listbox

Class library usage, coding and language questions.
grahama
Posts: 8
Joined: Tue Apr 24, 2007 7:47 pm

Cannot read items in a listbox

Post by grahama » Thu Jun 14, 2007 7:07 pm

I am unable to read the entries in a listbox.

The app being tested uses what I believe are 3rd-party controls. In particular, a list box control uses the class name "ClaList_X" (where X is some hex value).

I can find the control using

Code: Select all

Control c = parent.FindControlId(id);
where id was found using RanorexSpy. But c.Text is an empty string.

I tried building a ListBox object:

Code: Select all

Ranorex.ListBox lb = new ListBox(c.Handle);
But again, lb.Text is an empty string.

I even tried using the element:

Code: Select all

Element e = c.Element;
Both e.Text and e.Name are empty strings. Searching through the child elements (and their children, and their children down about six levels) yielded nothing.

I've run out of ideas .. any suggestions?

Graham

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Jun 14, 2007 11:25 pm

Does RanorexSpy see the elements of the 3rd-party listbox?
(Please use the newest version from http://www.ranorex.com/products/spy.html).

If yes, what are the role and names of the elements?

Jenö
Ranorex Team

grahama
Posts: 8
Joined: Tue Apr 24, 2007 7:47 pm

Post by grahama » Fri Jun 15, 2007 8:22 pm

To clarify - the control is actually a custom ListView, not ListBox (my mistake). But the original post still applies - I cannot see any items or subitems.

I tried out RanorexSpy, and it canNOT see any of the rows in the listview (or even the column headers) as seperate elements. It always gives the same values no matter where in the control the mouse is.

Graham

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Sun Jun 17, 2007 8:05 pm

Can you please post us the name and manufacturer of the control.
I think it doesn't support accessibility, we should ask the company for the suggested way.

Jenö
Ranorex Team

grahama
Posts: 8
Joined: Tue Apr 24, 2007 7:47 pm

Post by grahama » Mon Jun 25, 2007 2:05 am

Unfortunately, we do not know the vendor who created the control - we are testing a 3rd party application without access to source.

I suspect that their design of the control has "hidden" this information.

But no worries - we found a workaround that makes it unnecessary to retrieive this information.

:D

saurabh
Posts: 20
Joined: Fri Jul 20, 2007 1:11 pm
Location: India
Contact:

Post by saurabh » Fri Jul 20, 2007 1:22 pm

Find this code i think it will be helpful as direct control is not working for list box
here form hold the handler of main application like cal.exe
String* DispListBoxTest(String*DispCompVal,String*DispCompName,Form*form,String*szStatus)
{
ListBox* lCtrl = form->FindListBox(DispCompVal);
if(lCtrl==0){
Console::WriteLine(S"Displayer Test List {0} not found",DispCompName);
szStatus = "Fail";
}
Mouse::MoveToControl(lCtrl);
lCtrl->Focus();
String* Listtext = lCtrl->SelectedText;
int itemcount = lCtrl->ItemCount;
for (int i=0; i < itemcount;i++){
String* Listtext = lCtrl->GetItemText(i);
Element *element = lCtrl->get_Element();//need more input to generalized
Element *listItem =element->FindChild(Ranorex::Role::ListItem, Listtext, NULL);
Mouse::ClickElement(listItem);
Console::WriteLine(S"Displayer Test Case {0} Execution success",
Listtext);
szStatus = "Pass";
//break;
}
return szStatus;
}