Page 1 of 1

Problems with creating a Ranorex.Combobox

Posted: Tue Jun 16, 2009 9:45 am
by alen dibra
Hi

When I try to create a ComboBox like this:

Ranorex.Control control = null;
control = new Ranorex.ComboBox();

I get the Error: "'Ranorex.ComboBox' does not contain a constructor that takes '0' arguments (CS1729)"
After looking Ranorex.ComboBox up in the Documentation, it said that a Element is needed (Which is normally not needed)

How can I make this work?

Thanks in Advance, Alen

Re: Problems with creating a Ranorex.Combobox

Posted: Tue Jun 16, 2009 12:28 pm
by Support Team
Alen,
What are you exactly trying to accomplish ?
If you want to automate a specific combo box, just use:

ComboBox myComboBox = "/combobox[..]";

The path can usually be found by using the Ranorex Spy tool.
If you are working with Ranorex Studio you can just drag-drop the element from the Element Tree
into your source code, or use the repository to access the element.

For more information, please hava a look at this:
http://www.ranorex.com/support/user-gui ... apter.html

Michael
Ranorex Team

Re: Problems with creating a Ranorex.Combobox

Posted: Tue Jun 16, 2009 1:41 pm
by alen dibra
Hi Michael,

what I'm trying to accomplish is having one object(in that case I tried it with control).
I want to be able to use this object to create an instance of a combobox or button or list etc...(determined by a condition)

I would then be able to load the rxpath to this instance... in my particular case this is needed...

It seems like there's a problem with converting control into combobox, but i havent found another way.

mvH Alen

Re: Problems with creating a Ranorex.Combobox

Posted: Tue Jun 16, 2009 3:34 pm
by Support Team
Hmm, am I guessing right that you want to use different adapter types (ComboBox, Control, ...) with the same element? If that's right you can do that the following way:
Ranorex.Unknown elem1 = "pathToTheElement"; // elem1 found directly through RxPath
Ranorex.Unknown elem2 = myRepo.MyAppFolder.MyElement; // elem2 got via Ranorex repository

// to access different attributes/actions of the element we need
// to create the corresponding adapter
Ranorex.Control control1 = elem1.As<Ranorex.Control>(); // returns null if elem1 is no Control
Ranorex.Control control2 = new Ranorex.Control(elem2); // raises an exception if elem2 is no Control

// now we can use the Control actions/attributes
object propertyValue = control1.GetPropertyValue("SomePropertyName");
Regards,
Alex
Ranorex Support Team

Re: Problems with creating a Ranorex.Combobox

Posted: Wed Jun 17, 2009 7:59 am
by alen dibra
That is exactly what I needed.

Thank you very much!

mvH Alen