Environment Variables:


        Some Times, QuickTest can insert a value from the Environment Variable list, which is a list of variables and corresponding values which can be accessed through out the script.

The following are the several types of Environment Variables available’

  1. Built-in.
  2. User-Defined – Internal.
  3. User-Defined – External.
  4. Predefined.
Built-In Environment Variables:

          QuickTest provides set of built-in variables that enable you to use the current information about the test and the QuickTest computer running your test. These can include the test name, the test path, the OS type and Version, and the local host name.


NOTE:

  1. Throughout the test run, the value of the environment variable remains same, regardless of number of iterations, unless you change value of the variable programmatically in your script.
User-Defined – Internal:

          Variables that define within the test. These variables are saved with the test and are accessible only within the test in which they were defined.
User-Defined – External:

          Variables that you predefine in the active external environment variables file (in the form of XML file). You can create as many files as you want and select an appropriate file for each test, or change files for each test run.

To Create an External Environment Variables File:

  1. Create an xml file using the editor of your choice.
  2. Type <Environment> on the first line.
  3. Type each variable name-value pair within <Variable> elements in the following format:
<Variable>
<Name> this is the first variable’s name</Name>
<Value> this is the first variable’s value</Value>
<Description> This text is optional and can be used to add comments. It is shown only in the XML not in QuickTest</Description>
</Variable>

  1. Type </Environment> on the last line.
  2. Example.
<Environment>
<Variable>
<Name>Address1</Name>
<Value>25 Yellow Road</Value>
</Variable>
<Variable>
<Name>Address2</Name>
<Value>Greenville</Value>
</Variable>
<Variable>
<Name>Name</Name>
<Value>John Brown</Value>
</Variable>
<Variable>
<Name>Telephone</Name>
<Value>1-123-12345678</Value>
</Variable>
</Environment>

  1. Save the file to the required location.
To select the active external environment variables file:

  1. Select File > Settings to open the Test Settings dialog box.
  2. Click the Environment node.
  3. Select User-defined from the Variables type list.
  4. Select the Load variables and values from external file (reloaded each run session) check box.
  5. Use the browse button or enter the full path of the external environment variables file you want to use with your test. The variables defined in the selected file are displayed in blue in the list of user-defined environment variables.


NOTE:

  1. The external environment variable values are designated as read-only within the test.

No comments:

Post a Comment