Hi all,
Is it possible (if possible without writing code) to use a variable when defining another variable? (Repository variable, Recording variable and / or Global Parameter) What I'd like to to is to "concatenate" two or three variable into one.
Example:
$progpath = "C:\Program Files"
$applicationPath = "\myApp\bin"
$application = "\myapp.exe"
This is what I want:
$myApplication = $progpath + $applicationPath + $application
So the value of $myApplication would be "c:\Program Files\myApp\bin\myapp.exe"
If it is not possible without writing code, how would I define those variables and how would I access them when defining a repository variable or a recording variable?
Christoph
Using a variable in a variable definition
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Using a variable in a variable definition
Hi Christoph,
It is unfortunately not possible to create a new recording variable or repository variable out of other variables without using code, but you can concatenate more variables in the RxPath: "form[@title='...'+$newvariable+'...'+$newvariable1+'...']"
Regards,
Markus
Ranorex Support Team
It is unfortunately not possible to create a new recording variable or repository variable out of other variables without using code, but you can concatenate more variables in the RxPath: "form[@title='...'+$newvariable+'...'+$newvariable1+'...']"
Regards,
Markus
Ranorex Support Team
Re: Using a variable in a variable definition
Hi Markus,
Thank you for your response. This means I will need to decide, if I define the concatenate variables in code or if I'm better off doing so in an Excel spreadsheet. My main concern is easy maintenance in case a folder path changes sometime in future for one reason or another. I then only want to make one change.
Christoph
Thank you for your response. This means I will need to decide, if I define the concatenate variables in code or if I'm better off doing so in an Excel spreadsheet. My main concern is easy maintenance in case a folder path changes sometime in future for one reason or another. I then only want to make one change.
Christoph
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Using a variable in a variable definition
Hello Christoph,
You can specify one global parameter for each application. In case that the path of the application changes you only have to modify the global parameter. The other way is to define the paths in a data table and change them there as you described.
Regards,
Bernhard
Ranorex Support Team
You can specify one global parameter for each application. In case that the path of the application changes you only have to modify the global parameter. The other way is to define the paths in a data table and change them there as you described.
Regards,
Bernhard
Ranorex Support Team
Re: Using a variable in a variable definition
Hi Bernhard,
Thanks for your response. I think I will pursue this approach:
- I will define a global parameter for each variable that I need (more or less)
- in the test case I bound recorder variable to the appropriate global parameter
- I create a code class that contains all definitions that I need
- I create a coded module. This module sets the global parameters dynamically (only once). The values are supplied by the code class that holds all the definitions
- I create a "Testcase" that runs the coded module
- This testcase I run *once* at the very beginning of the test suit
The advantage of this is:
- The global parameters get set at runtime at the very beginning of the test suit.
- all recorder variable will be bound in a test case. I won't get a warning, that I do have unbound variables
- All values are defined at one place, the code class.
- In the code class I can concatenate definitions
Christoph
Thanks for your response. I think I will pursue this approach:
- I will define a global parameter for each variable that I need (more or less)
- in the test case I bound recorder variable to the appropriate global parameter
- I create a code class that contains all definitions that I need
- I create a coded module. This module sets the global parameters dynamically (only once). The values are supplied by the code class that holds all the definitions
- I create a "Testcase" that runs the coded module
- This testcase I run *once* at the very beginning of the test suit
The advantage of this is:
- The global parameters get set at runtime at the very beginning of the test suit.
- all recorder variable will be bound in a test case. I won't get a warning, that I do have unbound variables
- All values are defined at one place, the code class.
- In the code class I can concatenate definitions
Christoph