Dear All,
I am using C# quite a lot in my tests and I have a question. I often have expressions like
repo.A.B.C.D.x
repo.A.B.C.D.y
is there a way to define some object ob that will represent repo.A.B.C.D such that I can have the definition and then
ob.x
ob.y
? That would be cool!
Thanks!!!
shortcuts
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
Hi,
No, there is no such a thing (as far as I know). But are you aware that you can actually pass a repo item to your methods as a parameter? This way you can either reduce the amount of hardcoded repo items in code and also the name of repo item in code will be much shorter
It's definitely not a very good idea to address the repo items directly in code. You should always pass them as a parameter.
No, there is no such a thing (as far as I know). But are you aware that you can actually pass a repo item to your methods as a parameter? This way you can either reduce the amount of hardcoded repo items in code and also the name of repo item in code will be much shorter

Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
Hi.
Thanks! Do you have a good reference on passing repo items as parameters?
What I find confusing is that for a repo obj ob, sometimes I need to use ob itself and sometimes
obInfo. I could not find a way to handle this without having to pass two objects.
Thanks again for your help!
Thanks! Do you have a good reference on passing repo items as parameters?
What I find confusing is that for a repo obj ob, sometimes I need to use ob itself and sometimes
obInfo. I could not find a way to handle this without having to pass two objects.
Thanks again for your help!
Re: shortcuts
In my opinion, it's always best to pass the element as RepoItemInfo. The difference between Info and Adapter object is, that with Info object, Ranorex access element attributes (some of them) without actually accessing the element's UI. So it does not wait for the element appearance and does not throw an exception in case the element is not found. So this is why it's better to use Info object to pass the repo element to method. However, the info object does not have access to all element's attributes. So you may need to convert the Info object to Adapter (using CreateAdapter or CreateAdapters) later in your code.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
Thanks!
I had a problem. I used CreateAdapter to get the adapter, to call Click() on the item, but the click simply did not happen. I suppose I will have to try some more.
I had a problem. I used CreateAdapter to get the adapter, to call Click() on the item, but the click simply did not happen. I suppose I will have to try some more.
Re: shortcuts
Sure, this is possible. The repository generates distinct types (inheriting from RepoGenBaseFolder) for every folder/appfolder. So, why not just give it a try?giuseppe.lacagnina wrote:is there a way to define some object ob that will represent repo.A.B.C.D such that I can have the definition and then

var appFolder = repo.A; var parentFolder = appFolder.B; var someFolder = repo.A.B.C;
The "RepoItemInfo" object is just a description of the repository item, i.e. it knows the RxPath to search, the search timeout, the repository folder structure, and so on. It's just a repository object, not a real UI element.giuseppe.lacagnina wrote:What I find confusing is that for a repo obj ob, sometimes I need to use ob itself and sometimes
obInfo.
To get an element you can interact with, i.e. an object that represents a UI element, you need to search for the corresponding RxPath the RepoItemInfo object stores, which will then give you the corresponding Adapter if (and only if) the element is found within the search timeout. The CreateAdapter method will just do that: it searches for the RxPath associated with the info object and returns the adapter if it finds the element.
Regards,
Alex
Ranorex Team
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
Well, thanks a lot for the excellent ideas! I will try them out immediately and come back here in case of questions.
Cheers,
Giuseppe
Cheers,
Giuseppe
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
I tried, in a method (item is of RepoItemInfo)ahoisl wrote: To get an element you can interact with, i.e. an object that represents a UI element, you need to search for the corresponding RxPath the RepoItemInfo object stores, which will then give you the corresponding Adapter if (and only if) the element is found within the search timeout. The CreateAdapter method will just do that: it searches for the RxPath associated with the info object and returns the adapter if it finds the element.
Adapter adapter = item.CreateAdapter(true);
but I get the following compilation error
The type arguments for method 'Ranorex.Core.Repository.RepoItemInfo.CreateAdapter<T>(bool)' cannot be inferred from the usage. Try specifying the type arguments explicitly. (CS0411) -
Re: shortcuts
You have to specify an adapter type, e.g. Button or Form, but you have to make sure that the element supports that adapter. You can always use Unknown, which does not have any required capabilities:
Alex
Ranorex Team
var adapter = item.CreateAdapter<Ranorex.Unknown>(true);Regards,
Alex
Ranorex Team
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: shortcuts
Done, it works. Thanks a million!!!
Giuseppe
Giuseppe