Page 1 of 1
Creating an "element" from xpath
Posted: Mon Apr 26, 2010 10:10 am
by KeySam
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.
Re: Creating an "element" from xpath
Posted: Mon Apr 26, 2010 9:38 pm
by Support Team
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.
Regards,
Alex
Ranorex Support Team