Page 1 of 1

How do I use Create for an Adapter

Posted: Fri Sep 03, 2010 11:26 pm
by Aracknid
I'm trying to create a general function that will click on what ever type of control I'm passing in.

How do I do this in code? (I'm not using the repository)

Here's what I know while in my function (based on what was passed in).

- The RxPath as a string to the control I want, such as a button, or a combo, or a checkbox
- A string that contains the word for the control, such as "button"

What I was trying to do (not sure it is correct), is something like this:
Public function Click_Adapter(ByVal ControlIndex as enumControls) as boolean

    Dim MyElement as Ranorex.Core.Element
    Dim MyAdapter as Ranorex.Adapter = Nothing

    MyElement = MyControls(ControlIndex).RxPath 'This finds the element

    'Note that MyControls(ControlIndex).Type = "Button" 
    'in this example even though it is not used in my sample code

    'This is the part where I don't know what to do
    'I cannot click the element because ".click" is not possible on MyElement
    'So I figure I need to use an adapter

    MyAdapter = Adapter.Create( ???, MyElement)  'What do I put here for adapterType??

    MyAdapter.click

end Function
Thanks,

Aracknid

Re: How do I use Create for an Adapter

Posted: Sat Sep 04, 2010 9:00 pm
by sdaly
Not sure if this is what you are looking for....but can't you just do the following?

Public Sub click(strRanorexPath As String)
Dim unknownItem As Ranorex.Unknown = strRanorexPath
unknownItem.Click
End Sub

Re: How do I use Create for an Adapter

Posted: Mon Sep 06, 2010 9:41 pm
by Aracknid
I'm not at work today (Holiday here in North America), but look forward to trying this tomorrow.

In the meantime, out of curiosity, can someone tell me what I should put in the code of my original post for Adapter.Create (where I put ???). Even if this is wrong for what I'm trying to do, I want to learn what I should put there in case I need to use this in the future.

Thanks,

Aracknid.

Re: How do I use Create for an Adapter

Posted: Tue Sep 07, 2010 9:04 am
by Support Team
Hi,

Please read following documentations about Ranorex Adapters:
http://www.ranorex.com/support/user-gui ... apter.html
http://www.ranorex.com/Documentation/Ra ... dapter.htm

Regards,
Peter
Ranorex Team