Environment Object
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.
Methods and Properties
ExternalFileName | Returns the name of the loaded external environment variable file specified in the Environment pane of the Test Settings dialog box. |
LoadFromFile | Loads the specified environment variable file. |
Value | Sets or retrieves the value of environment variables. |
ExternalFileName Property
Description
Returns the name of the loaded external environment variable file specified in the Environment pane of the Test Settings dialog box. If no external environment variable file is loaded, returns an empty string.
Syntax
Environment.ExternalFileName
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 "Environment.xml"
End If
'display value of one of the Environment variables from the External file
msgbox Environment("MyVarName")
LoadFromFile Method
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>
For more details about environment variable files, see the OpenText Functional Testing User Guide.
Syntax
Environment.LoadFromFile bstrFileName
Argument | Type | Description |
---|---|---|
bstrFileName | String | The name of the environment variable file to load. |
The following example loads the MyVariables.xml file.
Environment.LoadFromFile "MyVariables.xml"
Value Property
Description
Retrieves the value of environment variables. 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.Value(bsName) = var_Value
To retrieve the value of a loaded environment variable:
var_Value = Environment.Value(bsName)
Argument | Type | Description |
---|---|---|
bsName | String | The name of the environment variable. |
The following example creates a new internal user-defined variable named MyVariable with a value of 10, and then retrieves the variable value and stores it in the MyValue variable.
Environment.Value("MyVariable")=10
MyValue=Environment.Value("MyVariable")
Note: You could omit the word Value
in the statement above, because Value
is the default property for the Environment object.
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object