Dear All,
I have added to my solution a Class Library, which has methods shared by many test cases in a project from the same solution.
I would like to know whether it is possible to make the repository of the solution visible by the class library.
The application has an error dialog which keeps popping up, and I would like to define a method to deal with it inside my class library. This would let me define the method in one place and just call it inside the modules.
The problem is that I need the class library to access the repo items. Is that possible? Can anyone help?
Thanks!!!
Ranorex Class Library and repositories
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: Ranorex Class Library and repositories
Hi Giuseppe,
If I understand your problem right, you want to access the solution's repo from the class library? In this case, all you need to do is to instantiate repository in the class library of your choice, like this:
If I understand your problem right, you want to access the solution's repo from the class library? In this case, all you need to do is to instantiate repository in the class library of your choice, like this:
Just modify this line of code according to your solution and put it after the code module constructor. Hope this helps?private static YourSolutionName.RepositoryName repo = SolutionName.RepositoryName.Instance;
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: Ranorex Class Library and repositories
Well, sounds very good! I just had no idea how to achieve this properly.
Thanks a lot!

Thanks a lot!



- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: Ranorex Class Library and repositories
I have a problem.
In order to instantiate the repo in the class library, I have to add a reference of the project containing the repo to the class library.
This project, however, contains a reference to the class library and therefore there is a circularity issue.
Any way out of this?
Thanks!
In order to instantiate the repo in the class library, I have to add a reference of the project containing the repo to the class library.
This project, however, contains a reference to the class library and therefore there is a circularity issue.
Any way out of this?
Thanks!
Re: Ranorex Class Library and repositories
No, there's no way around it. You can't (and shouldn't) reference the test project in your library. The point of a library is that it can be used by many different projects. Referencing the test project in your library means your library is no longer independent.
If you want to use items from your project in methods in your library, your best bet is to define the library modules so that they take either a RepoItemInfo or Adapter object as parameters.
Then, in your test project, pass the element from your repo directly into the library method call.
Also, when you create the library methods, make sure that they are very generic internally. You want to make them so that any test in the future that needs that functionality can use them.
In addition, if you find that you have to have references to a specific test project in a library method, then that method probably shouldn't be in the library, but in the test project.
If you want to use items from your project in methods in your library, your best bet is to define the library modules so that they take either a RepoItemInfo or Adapter object as parameters.
Code: Select all
public void MyLibraryMethod(RepoItemInfo myItemInfo) {
}
public void MyLibraryMethod(Ranorex.Adapter myAdapter) {
}
Then, in your test project, pass the element from your repo directly into the library method call.
Code: Select all
RepoItemInfo myButtonInfo = repo.MyApp.MyButtonInfo;
MyLibrary.MyLibraryMethod(myButtonInfo);
In addition, if you find that you have to have references to a specific test project in a library method, then that method probably shouldn't be in the library, but in the test project.
Shortcuts usually aren't...
- giuseppe.lacagnina
- Posts: 113
- Joined: Fri Sep 18, 2015 10:25 am
- Location: Brunn am Gebirge, Vienna, Austria
Re: Ranorex Class Library and repositories
Ok, I will try this approach!
Thanks a lot for the excellent explanation.
Giuseppe
Thanks a lot for the excellent explanation.
Giuseppe