Creating an "element" from xpath

Ranorex Studio, Spy, Recorder, and Driver.
Posts: 15
Joined: Tue Jul 28, 2009 9:52 am

Creating an "element" from xpath

Post by KeySam » Mon Apr 26, 2010 10:10 am

After i get my xpath with findfrompoint() now i want to generate a special Adapter(Button, List, Cell...). I found the GetCapabilityForTailNodeTest method that basicly returns what i want, now i wish i could just generate the right Adapter without using a huge switch case method. So my question is is there a method that can generate the different addapters after with help of GEtCapabilityForTailNodeTest()?

Thanks in advance.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: Creating an "element" from xpath

Post by Support Team » Mon Apr 26, 2010 9:38 pm

You could use the Ranorex.Core.ElementEngine.AdapterTypes dictionary to map from the capability name to the corresponding adapter type and then create a adapter of that type using the Adapter.Create(Type, Element) (see API Documentation) method.

However, I'm not 100% sure that this is what you want to accomplish. In order to use special methods from the Button or List adapter, you will need a switch statement anyway, since you need to check if the element supports that capability. If you don't need special method, but one of the Adapter base methods (see API Documentation) like Click, just create an Unknown adapter and call the method on that adapter instance.

Ranorex Support Team