Passing Ranorex object to functions : General Questions

Passing Ranorex object to functions

Ask general questions here.

Passing Ranorex object to functions

Postby Aracknid » Thu Sep 29, 2011 8:38 pm

Hi,

I was wondering if what I was doing was smart or efficient, or if there was a better way.

I created a function to click on a ranorex object type, such as an InputTag or an ImgTag, when I pass it in.

My click function is declared as such: Function Click(MyControl as Ranorex.Unknown)

When I'm in another function and I declare an object, such as Ranorex.ImgTag, and I assign something to it, when I want to click on it I call my click function as follows: click(MyImgTag.As(of Ranorex.Unknown))

This works, but I'm wondering if there is a way I can just pass the object without converting it to unknown, since I often forget to do it and it's annoying to do? Obviously if I don't convert it it won't compile.

Another thing I've noticed, is I can decalre my click function as such: Click(MyControl as Ranorex.Core.Element). This allows me to pass in anything without converting it first to unkown and allows me to do some basic things, like check if it's visible. But I cannot do more specific things like click on it unless I convert the element to something specific using Adapter.Create.

FYI: I have my own click function (and other functions like this) because I need to do work to figure out if it's visible and if I should scroll it into view)

Thanks,

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

Re: Passing Ranorex object to functions

Postby sdaly » Fri Sep 30, 2011 9:17 am

Can you try changing the parameter type to Ranorex.Adapter?
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: Passing Ranorex object to functions

Postby Aracknid » Thu Oct 06, 2011 11:26 pm

Yes, that worked. Thanks.

I find it confusing to know when to use Ranorex.Adapter, Ranorex.Core.Element, Ranorex.Unknown, or just a specific adapter...

Aracknid.
User avatar
Aracknid
 
Posts: 126
Joined: Tue Aug 10, 2010 4:23 pm
Location: Toronto, Ontario, Canada

Re: Passing Ranorex object to functions

Postby artur_gadomski » Tue Oct 11, 2011 10:45 am

Maybe it's because I mainly work with Window Forms but I never use Element for anything. And if I see Unknown I get worried because that generally meant Ranorex had problems detecting something. In most places I use specific adapters because I want to perform a specific actions i.e. expand a tree, click a button.
User avatar
artur_gadomski
 
Posts: 125
Joined: Mon Jul 19, 2010 7:55 am
Location: Copenhagen, Denmark

Re: Passing Ranorex object to functions

Postby Support Team » Tue Oct 11, 2011 1:23 pm

Hi,

And if I see Unknown I get worried because that generally meant Ranorex had problems detecting something.

If your controls are recognized as "Unknown" or "Element", Ranorex cannot assign them a role. You can't use special attributes or actions with these elements, but you can usually still create a path that identifies the element to execute minimally mouse clicks or such minimally actions.
Instances of the element class dynamically implement optional Capabilities, as well as numerous standard properties.
Unknown represents a UI element which cannot be further categorized.


Regards,
Markus
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to General Questions

Who is online

Users browsing this forum: No registered users and 0 guests