How do I use Create for an Adapter : Automation API

How do I use Create for an Adapter

Class library usage, coding and language questions.

How do I use Create for an Adapter

Postby Aracknid » Sat Sep 04, 2010 12:26 am

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
Aracknid
 
Posts: 126
Joined: Tue Aug 10, 2010 4:23 pm
Location: Toronto, Ontario, Canada

Re: How do I use Create for an Adapter

Postby sdaly » Sat Sep 04, 2010 10: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
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: How do I use Create for an Adapter

Postby Aracknid » Mon Sep 06, 2010 10: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
Aracknid
 
Posts: 126
Joined: Tue Aug 10, 2010 4:23 pm
Location: Toronto, Ontario, Canada

Re: How do I use Create for an Adapter

Postby Support Team » Tue Sep 07, 2010 10: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
User avatar
Support Team
Site Admin
 
Posts: 4844
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: Support Team and 0 guests