Using same repository for multiple environments

Ask general questions here.
Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Using same repository for multiple environments

Post by Martin » Tue Nov 03, 2015 12:12 pm

Hello!

We have the need to start testing multiple environments. Even though the URL changes between them, all the elements and objects are identical. The best solution would be to have only 1 repository between them so minimum tweeking would have to be done.

I've done some deep google-ing and haven't actually come across a specific solution. The issue on hand is the need to change the repository base Dom objects domain address depending of against which environment the tests will be run. (Probably a need to set different Run Configurations which will set the dom objects domain before the tests actually start).

For changing the dom objects domain I tried to follow this forum topic:
http://www.ranorex.com/forum/how-to-han ... t4765.html

But i'm not so sure about this implementation for 2 reasons:
1) I have no access to modifying the TestRepository.cs (Not so sure about editing the file manully in the project folder)
2) It is also stated in the file that it gets regenerated and might loose all my changes done there

So please feel free to suggest different solutions for this need and any further input on solving this is very helpful and appreciated.

PS! A further question: If it actually is possible to do this by adding a userCode module, will the dom url be changed and keep it's changed value throughout the test suit run or would there be a need to assign the correct URL on each TC or recording module sepperately?

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Using same repository for multiple environments

Post by Martin » Tue Nov 03, 2015 12:15 pm

Also I have a hunch that the variable in the ...Repository.cs for the example forum thread is actually auto-generated (a global variable was added or something). But couldn't reproduce that effect myself. (Probably have to build the project as well after the variable gets added. Gonna test this out)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using same repository for multiple environments

Post by odklizec » Tue Nov 03, 2015 12:34 pm

Hi,

At first, you are not supposed to edit repository cs file. This file is autogenerated by Ranorex and any change you might do in this file will be lost with next build of solution! This is why the file is read only.

At next, it's not recommended to use variables in DOM xpath. If you add variable to DOM level xpath, each module using repository will change and each module will now have the same repository variable, which you will have to bind. Otherwise, the variable will be displayed as unbound and this will make your tests to fail. And I think you definitely don't want to have the same variable in every single module ;) It's not a big deal, but it creates a mess in solution.

I think the easiest way to solve your issue is to add logical operator to DOM xpath, like this...

Code: Select all

/dom[@domain='your.domain_1.com' or @domain='your.domain_2.com']
That's it! From now on, you can use the same repository with both test sites. Hope this helps? ;)
Pavel Kudrys
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

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Using same repository for multiple environments

Post by Martin » Tue Nov 03, 2015 1:02 pm

odklizec wrote:Hi,

At first, you are not supposed to edit repository cs file. This file is autogenerated by Ranorex and any change you might do in this file will be lost with next build of solution! This is why the file is read only.

At next, it's not recommended to use variables in DOM xpath. If you add variable to DOM level xpath, each module using repository will change and each module will now have the same repository variable, which you will have to bind. Otherwise, the variable will be displayed as unbound and this will make your tests to fail. And I think you definitely don't want to have the same variable in every single module ;) It's not a big deal, but it creates a mess in solution.

I think the easiest way to solve your issue is to add logical operator to DOM xpath, like this...

Code: Select all

/dom[@domain='your.domain_1.com' or @domain='your.domain_2.com']
That's it! From now on, you can use the same repository with both test sites. Hope this helps? ;)
Haha!

You really are a Ranorex Guru! Thanks

I have no clue why I didn't approach the issue on the xPath side itself even though I believe I'm quite familiar with it already. Didn't even cross my mind.

Again, big thanks!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Using same repository for multiple environments

Post by odklizec » Tue Nov 03, 2015 1:15 pm

Hi,

I'm glad I could help. Honestly, I'm far from being a Ranorex guru ;) Most of my Ranorex knowledge is from this forum. It's a great example how important is to have well organized and active community forum.
Pavel Kudrys
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