Dynamic identification of component types : Automation API

Dynamic identification of component types

Class library usage, coding and language questions.

Dynamic identification of component types

Postby jtruppia » Sat Oct 29, 2011 1:14 am

I have the following problem.
I've got a dictionary, where the keys corresponds to labels in my UI, and the values correspond to the value I must set in each control associated with that label.
The problem is that I don't know at compile time what type will the component have (it can be a textbox, combo, list, etc)
Each component shares the parent with the label, so that's the way I'm locating it.
But after that, I want to be able to create adapters (or elements) for each component, and be able, at runtime, to determine the type and using that, change the value in the appropriate way.
Is there any method that given an adapter or element can determine its type, or its capabilities??
jtruppia
 
Posts: 11
Joined: Sat Oct 22, 2011 1:35 am

Re: Dynamic identification of component types

Postby Patrik » Thu Nov 03, 2011 6:34 pm

Hey - i'm not sure if this is what you need, but with this method you get the correct adapter for the component if you have its RxPath:

Code: Select all
public Adapter findObject(string path, int timeout) {
    Element element = Host.Local.FindSingle(path, timeout);
    RxPath rxPath= new RxPath(path);
    string capabilityName= rxPath.GetCapabilityForTailNodeTest().Name;
    System.Type adapterType = Ranorex.Core.ElementEngine.Instance.AdapterTypes[capabilityName];
    return Adapter.Create(adapterType, element);
}


Greetings,
Patrik
Patrik
 
Posts: 13
Joined: Fri Sep 02, 2011 3:56 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests