Environment variable in persistent variables declaration
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Environment variable in persistent variables declaration
I want to use a Windows environment variable in the persistent variables section of a keyword test.
E.g. Something line InstallFolder is %TEMP%\MyAppLocation.
Using the variable InstallFolder works fine when defining the tested apps. E.g MyApp is $(InstallFolder)\MyApp.exe. The application starts as expected.
But when adding a check in JavaScript to verify if the InstallFolder folder exists, the check fails because the variable %TEMP% is not expanded.
E.g. aqFileSystem.Exists(Project.Variables.InstallFolder) returns false because Project.Variables.InstallFolder returns the string %TEMP%\MyAppLocation and not <Where ever my temp folder is>\MyAppLocation.
How can I fix this?
I'm new to TestComplete. So if my question may be a little bit unprecise. Hope it is not too confusing ...
TestComplete 14.40
Windows 10
Scripting language JavaScript
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let's see the actual code from both calls. It's probably just a syntax difference but we need to see it in order to help.
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What's the best way to show the code?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can copy paste or insert a screenshot. Up to you.
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have some environment variables directly avaiable with Sys.OSInfo object.
For example, to get the specific value of %TEMP% you must use Sys.OSInfo.TempDirectory
For other environment variables:
For general use for environment variables:
https://support.smartbear.com/testcomplete/docs/testing-with/advanced/environment-variables.html
Un sourire et ça repart
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Seems that the environment variable is not expanded automatically.
Variables:
Tested apps using the variables:
Test case:
Value of Project.Variables.InstallFolder at breakpoint
Is there any way to expand environment variables when defining project variables in the persistent variables window?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rasmus , have you tried what Benoit suggested above ? It seems to be what you are looking for.
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
the solution Benoit suggested was not exactly what I'm looking for. Using the %TEMP% variable was an example only. But anyway - I'm using C:\Test now for my tests. Works fine on all my windows machines.
Rasmus
