How do I use Create for an Adapter

Class library usage, coding and language questions.
User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

How do I use Create for an Adapter

Post by Aracknid » Fri Sep 03, 2010 11:26 pm

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

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: How do I use Create for an Adapter

Post by sdaly » Sat Sep 04, 2010 9:00 pm

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

User avatar
Aracknid
Posts: 388
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: How do I use Create for an Adapter

Post by Aracknid » Mon Sep 06, 2010 9:41 pm

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.

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

Re: How do I use Create for an Adapter

Post by Support Team » Tue Sep 07, 2010 9:04 am

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