Wednesday, 16 September 2015

ENVIRONMENT VARIABLES IN QTP


ENVIRONMENT VARIABLES:

Description :
Enables you to work with environment variables.
You can set or retrieve the value of environment variables using the Environment object. You can retrieve the value of any environment variable. You can set the value of only user-defined, environment variables.
Syntax :
To set the value of a user-defined, environment variable:
Environment (VariableName) = NewValue

To retrieve the value of a loaded environment variable:
CurrValue = Environment (VariableName)

Argument
Type
Description
VariableName
String
The name of the environment variable.
NewValue
Variant
The new value of the environment variable.
CurrValue
Variant
The current value of the environment variable.
-------------------------------------------------------------------------------------------------
Environment.ExternalFileName:

Description :
Returns the name of the loaded external environment variable file specified in the Environment tab of the Test Settings dialog box. If no external environment variable file is loaded, returns an empty string.
Syntax:
Environment.ExternalFileName
Example :
The following example uses the ExternalFileName property to check whether an environment variable file is loaded, and if not, loads a specific file and then displays one of the values from the file.
'Check if an External Environment file is loaded and if not, load it.
fileName = Environment.ExternalFileName
If (fileName = "") Then
       Environment.LoadFromFile("C:\Environment.xml")
End If
'display value of one of the Environment variables from the External file
msgbox Environment("MyVarName")
-------------------------------------------------------------------------------------------------
Environment.LoadFromFile filename

Description:
Loads the specified environment variable file. The environment variable file must be an XML file using the following syntax:
<Environment>
       <Variable>
              <Name>This is the first variable's name</Name>
              <Value>This is the first variable's value</Value>
       </Variable>
</Environment>
Note: You can also continue to use your QuickTest Professional 6.5 environment files (.ini format).
For more information about environment variable files, refer to the QuickTest Professional User's Guide.
Syntax :
Environment.LoadFromFile(Path)
Argument
Type
Description
Path
String
The path of the environment file to load.
Example
The following example loads the MyVariables.xml file.
Environment.LoadFromFile("C:\QuickTest\Files\MyVariables.xml")

No comments:

Post a Comment