How to pass in repo item in method and access it's children

Ask general questions here.
pksy
Posts: 10
Joined: Fri Dec 16, 2011 7:06 pm

How to pass in repo item in method and access it's children

Post by pksy » Thu Jan 12, 2012 7:57 pm

Let's say my repository is structured as follows:

Main -> Summary -> Tab1
-> Tab2
-> Detail -> Report
-> Additional Info

Is there a way for me to pass in the "Main" repo item into a method as a parameter and within that method, be able to access the children of "Main" repo item? If this is possible, could somebody give me an example of what the method would look like sepcifically the parameter type?

void method(xxx repoItem)
{
repoItem.Summary.Tab1
repoItem.Detail.Report
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to pass in repo item in method and access it's children

Post by Support Team » Mon Jan 16, 2012 6:41 pm

Just have a look at the type of the "Main" repo item, it should be something like "MainAppFolder" or "MainFolder". The full type would be something like "YourRepositoryFolders.MainAppFolder" if your repository is called "YourRepository". You can then create a method like this:
void method(YourRepositoryFolders.MainAppFolder mainFolder)
{
    mainFolder.Summary.Tab1
    mainFolder.Detail.Report
}
However, I don't know your use case and, consequently, I don't know if that approach really suits your needs, because still you can only use that method for that very repository folder. It will not work for a folder that is "similar", e.g. has the same name and similar child repository items.
Besides, the type will always change if you rename your repository or the "Main" folder name.

Regards,
Alex
Ranorex Team
.
Image

pksy
Posts: 10
Joined: Fri Dec 16, 2011 7:06 pm

Re: How to pass in repo item in method and access it's children

Post by pksy » Mon Jan 16, 2012 8:20 pm

Thanks! This is what I'm looking for. However, instead of using YourRepositoryFolders.MainAppFolder mainFolder, is there to be able to pass in any AppFolder so I can use the method for any folder in my repository?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to pass in repo item in method and access it's children

Post by Support Team » Tue Jan 17, 2012 11:33 am

pksy wrote:is there to be able to pass in any AppFolder so I can use the method for any folder in my repository?
As I already tried to explain in my previous post, this is not really possible, since Ranorex creates a specific type for each folder in the repository.
All folders inherit from the same base type (RepoGenBaseFolder), but if you use that type for your method parameter, you won't be able to access any items inside the folder within the method. The reason is again that for each folder a different class is created.

Regards,
Alex
Ranorex Team
.
Image

nehas
Posts: 6
Joined: Tue Feb 14, 2012 1:55 pm

Re: How to pass in repo item in method and access it's children

Post by nehas » Tue Nov 06, 2012 2:07 pm

Is it possible to pass the entire path as the argument : repo.WebDocumentEloqua_Login1.IFrameTagEloquaMainFrame.SpanTagEvents__Surveys_.

Please suggest as I need the complete element path as the argument in the method.

Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to pass in repo item in method and access it's children

Post by Support Team » Wed Nov 07, 2012 4:29 pm

Hello,

You could try to call the 'AbsoluteBasePath' function of your repository item in order to use the full XPath in your method.

Regards,
Markus (T)
.
Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to pass in repo item in method and access it's children

Post by Support Team » Wed Oct 29, 2014 8:34 pm

Hello everyone,

I am happy to inform you that User Code actions now support arguments of different types, including repository items (RepoItemInfo or Adapter type)
A detailed description can be found on our website in the section User Code Actions.

Regards,
Bernhard
.
Image