How to get a combobox item ? Delphi form

Class library usage, coding and language questions.
claudio.souza
Posts: 6
Joined: Fri Nov 07, 2008 12:11 pm

How to get a combobox item ? Delphi form

Post by claudio.souza » Thu Nov 13, 2008 12:27 pm

Im working in a project for automating tests for an application made in Delphi. (version unknow)

With the Ranorex spy i can get the classname of the desired combo (TDBLookupComboBox) and also got the name of the list class (TPopupDataList).

How can i get the selected text ?

I'm using Ranorex 1.5 and VB.Net.

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 » Fri Nov 14, 2008 1:11 pm

How can i get the selected text ?
Normally, you can read the selected text of the combo as follows:
(The selected text is the value of the combo element.)

Code: Select all

ComboBox comboBox = form.FindComboBox("comboBox1");
Element comboElement = comboBox.Element.FindChild(Role.ComboBox);
String comboValue = comboElement.Value;
Console.WriteLine("Combo value= {0}", comboValue);
Jenö
Ranorex Team

claudio.souza
Posts: 6
Joined: Fri Nov 07, 2008 12:11 pm

the problem is name

Post by claudio.souza » Mon Nov 17, 2008 5:08 pm

the problem is that i can't get the combobox name...

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 » Mon Nov 17, 2008 5:29 pm

the problem is that i can't get the combobox name...
OK, you can also find the combo by class name:

Code: Select all

ComboBox comboBox = (ComboBox)form.FindClassName("TDBLookupComboBox");
Element comboElement = comboBox.Element.FindChild(Role.ComboBox);
String comboValue = comboElement.Value;
Console.WriteLine("Combo value= {0}", comboValue);
Please use also the second argument of the function FindClassName (instanceNumber) if you have more than one combo in your form.

Jenö
Ranorex Team