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
Passing Ranorex object to functions
Re: Passing Ranorex object to functions
Can you try changing the parameter type to Ranorex.Adapter?
Re: Passing Ranorex object to functions
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.
I find it confusing to know when to use Ranorex.Adapter, Ranorex.Core.Element, Ranorex.Unknown, or just a specific adapter...
Aracknid.
- artur_gadomski
- Posts: 207
- Joined: Mon Jul 19, 2010 6:55 am
- Location: Copenhagen, Denmark
- Contact:
Re: Passing Ranorex object to functions
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Passing Ranorex object to functions
Hi,
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
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.And if I see Unknown I get worried because that generally meant Ranorex had problems detecting something.
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