Using 2 different repositories

Ranorex Studio, Spy, Recorder, and Driver.
monkey2012
Posts: 77
Joined: Wed Sep 26, 2012 8:15 pm

Using 2 different repositories

Post by monkey2012 » Thu Jun 01, 2017 3:04 pm

Hi,

I have 2 repositories in my project for 2 different user interfaces:
1. TestProject_1Repository.rxrep
2. TestProject_2Repository.rxrep

In the code module:
TestProject_1Repository repo1 = TestProject_1Repository.Instance;
TestProject_2Repository repo2 = TestProject_2Repository.Instance;

I want to reuse the same code module for these 2 interfaces, for example:

if (interface1) repo = repo1
if (interface2) repo = repo2

and so, my code module should use only

repo.LoginWin.ButtonLogin.Click();

instead of
if (interface1)
repo1.LoginWin.ButtonLogin.Click();
if (interface2)
repo.2.LoginWin.ButtonLogin.Click();

Is it possible to do so? If yes, how can I assign repo = repo1 and repo = repo2 based on user interface selection?

Thanks

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Using 2 different repositories

Post by Vaughan.Douglas » Thu Jun 01, 2017 5:03 pm

There are a couple of ways you could work around this, but I'm not so sure it's a great idea. You might be better served with having a test suite with separate projects for interface 1 and 2. Otherwise you could simply create your objects to account for both interfaces in the RxPath.

To work around this all you really need to do is override the instance of your repository at run time which is fraught with dangers and pitfalls.
Doug Vaughan

monkey2012
Posts: 77
Joined: Wed Sep 26, 2012 8:15 pm

Re: Using 2 different repositories

Post by monkey2012 » Thu Jun 08, 2017 5:33 pm

Thanks for your answer

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Using 2 different repositories

Post by Vaughan.Douglas » Mon Jun 12, 2017 1:54 pm

monkey2012 wrote:Thanks for your answer
Best of luck, and please do come back and let the community know what you decide and how it goes. Your question is fairly common and If you come up with an elegant solution I'm sure it could benefit others, my self included.
Doug Vaughan