Using script variables in keyword tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2010
09:42 PM
06-30-2010
09:42 PM
Using script variables in keyword tests
Hi there folks, I am trying to call a script variable for use as a keyword test value.
The script variable holds the location of the current users desktop, and looks like ....
function desktopPath()
{
try
{
var wshShell = Sys.OleObject("WScript.Shell");
var desktopPath = (wshShell.ExpandEnvironmentStrings("%USERPROFILE%\\Desktop"));
Log.Message(desktopPath);
}
catch(exception)
{
Log.Error("Exception", exception.description);
}
}
I am trying to use "desktopPath" variable as the value of a step in my keyword test which saves a file.
I want to be able to re-use this "desktopPath" variable throughout my keyword test so that the need to hardcode filepaths is removed. I am aware that I could simply use a regular test variable and put the path in there, but the special folder %USERPROFILE% does not work there.
The use of %USERPROFILE% is crucial so that my keyword tests will work which ever system or user profile they are run on.
Hope that all makes sense, thanks.
The script variable holds the location of the current users desktop, and looks like ....
function desktopPath()
{
try
{
var wshShell = Sys.OleObject("WScript.Shell");
var desktopPath = (wshShell.ExpandEnvironmentStrings("%USERPROFILE%\\Desktop"));
Log.Message(desktopPath);
}
catch(exception)
{
Log.Error("Exception", exception.description);
}
}
I am trying to use "desktopPath" variable as the value of a step in my keyword test which saves a file.
I want to be able to re-use this "desktopPath" variable throughout my keyword test so that the need to hardcode filepaths is removed. I am aware that I could simply use a regular test variable and put the path in there, but the special folder %USERPROFILE% does not work there.
The use of %USERPROFILE% is crucial so that my keyword tests will work which ever system or user profile they are run on.
Hope that all makes sense, thanks.
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2010
10:50 PM
06-30-2010
10:50 PM
Hi,
Use a keyword test variable. In your code, assign the needed value to it. See the "Keyword Test Variables" help topic.
Use a keyword test variable. In your code, assign the needed value to it. See the "Keyword Test Variables" help topic.
------
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2010
12:39 AM
07-01-2010
12:39 AM
Using "%USERPROFILE%" in a keyword test variable does not work.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2010
01:41 AM
07-01-2010
01:41 AM
Hi,
Expand this environment variable in script and assign the result to a keyword test variable.
Expand this environment variable in script and assign the result to a keyword test variable.
------
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Yuri
TestComplete Customer Care Engineer
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
