Page 1 of 1

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

Posted: Thu Jan 12, 2012 7:57 pm
by pksy
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
}

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

Posted: Mon Jan 16, 2012 6:41 pm
by Support Team
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

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

Posted: Mon Jan 16, 2012 8:20 pm
by pksy
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?

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

Posted: Tue Jan 17, 2012 11:33 am
by Support Team
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

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

Posted: Tue Nov 06, 2012 2:07 pm
by nehas
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

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

Posted: Wed Nov 07, 2012 4:29 pm
by Support Team
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)

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

Posted: Wed Oct 29, 2014 8:34 pm
by Support Team
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