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
}
How to pass in repo item in method and access it's children
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to pass in repo item in method and access it's children
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:
Besides, the type will always change if you rename your repository or the "Main" folder name.
Regards,
Alex
Ranorex Team
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
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?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to pass in repo item in method and access it's children
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.pksy wrote:is there to be able to pass in any AppFolder so I can use the method for any folder in my 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
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
Please suggest as I need the complete element path as the argument in the method.
Thanks
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to pass in repo item in method and access it's children
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)
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)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to pass in repo item in method and access it's children
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
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