How to set different variable base on environment

Ranorex Spy, Recorder, and Studio.
Posts: 20
Joined: Tue May 05, 2015 11:25 am

How to set different variable base on environment

Post by eric.franc » Mon Jul 20, 2015 8:09 am


I have a little issue, on my dev machine one of the program I am testing is located under D:\myprogram2015\SP5\myprogram.exe.

On my test environment I use the setup package and the executable is installed under C:\program file\myprogram\myprogram.exe.

Is there a easy way to assign variable base on configuration ? in a similar way than visual studio.
I would then be able to easily be able to switch the runtime path.

Now when i have to make a modification I need to check the path each time, it is really time consuming and tiring.


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

Re: How to set different variable base on environment

Post by odklizec » Mon Jul 20, 2015 11:44 am


The easiest way is to create a module variable and use this module variable in RunApplication action, which should start your AUT. Then simply connect that variable with global parameter. Finally, your should start your your Ranorex test with command line parameter, containing the path to your app, e.g. yourtest.exe /pa:path_to_AUT. If Global Parameter is correctly connected with the module variable, the RunApplication action should start your AUT, provided via command line.

See this paragraph about running tests from command line... ... html#c4827

And this paragraph about data drive testing (using variables within recordings)... ... html#c2967

If you want to avoid using command line, you will have to read the path to AUT (from anywhere in your tested system, e.g. registry, environment variable, etc...) and pass the obtained path to global parameter or module variable. The best would be to do this in testsuite/test case [Setup] section.
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