cancel
Showing results for 
Search instead for 
Did you mean: 

how to define variables to be used in project run on a separte machine

Highlighted
Frequent Contributor

how to define variables to be used in project run on a separte machine

Hi,



I have defined variables in my script units as:



var toolpath = "C:\ProgramFiles(x86)\abc.exe"

var servername = "vmsa"



If I have to run the same project suite on an XP machine where toolpath = "c:\ProgramFiles\abc.exe" and run on server with servername ="vm2k3" ,then I have to modify the toolpath and servername across all units defined in the script . Can I not define variable somewhere as 'toolpath' and just change at one location instead of changing at every single location in the script. I read the help articles on the variables but did not understood how to define and use the variables.



How can I sove this ? If variables are to be defined in the variables section ,can you please describe the appropriate steps ?



Thanks.

Sumedha
3 REPLIES 3
Highlighted
Staff

RE: how to define variables to be used in project run on a separte machine

Hi,



You can obtain the machine name via the Sys.HostName property. As for the program files directory, use the ProgramFiles environment variable. Regarding environment variables, see here.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Frequent Contributor

RE: how to define variables to be used in project run on a separte machine

Hi Jared,



Thanks for the reply. I read the SQA forum reply for enviroment variables.Can you please give me an example how can we set the program files path on different machine.



for example : - The script line below displays the OS name but how can we make it to display the C:\ProgramFiles path .Does it need to have a special naming convention for different paths that we want to specify .


Log.Message("The used OS is: " + wshShell.ExpandEnvironmentStrings("%OS%"));



In test complete help files,there is an option TestedApp.Path where it is mentioned "Within the string specifying the path, the environment variable name must be enclosed in % signs, for example, “%USERPROFILE%”, “%WINDIR%”, “%SYSTEMROOT%”. "

How can I know these specific names that needs to be used .How is the "TestedApp.Path" used in the scripts?



Thanks,

Sumedha


.Message("The used OS is: " + wshShell.ExpandEnvironmentStrings("%OS%"));In test complete help files,there is an option TestedApp.Path where it is mentioned "Within the string specifying the path, the environment variable name must be enclosed in % signs, for example, “”, “”, “”. "How can I know these specific names that needs to be used .How is the "TestedApp.Path" used in the scripts?Thanks,Sumedha
Highlighted
Staff

RE: how to define variables to be used in project run on a separte machine

Hi,



You need to use the ProgramFiles variable. If you replace %OS% with %ProgramFiles%, this will give you the Program Files path on the current machine.



As for TestedApp.Path, it is a regular read-write string property. You can assign a value to it as to a regular variable (TestedApps.MyApp.Path = "something").
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors