UFT/QTP – Parameterization

UFT enables you to extend the scope of a basic test by replacing fixed values with parameters. This process is know as parameterization which increases the power and flexibility of test.

Types of Parameters

Depending upon the data, Parameterization is divided into 4 categories.

  1. Data Table Parameterization
  2. Test/Action Parameterization
  3. Environment variable Parameterization
  4. Random number Parameterization

Data Table Parameterization

A Data Table, similar to Microsoft Excel helps testers to create data driven test cases that can be used to run an Action multiple times.

The Data Table has two types of sheets – Global and Action (Local)

Local Data Table – Each action has its own private data table also known as local data table which is can also be accessed across actions.

Global Data Table – Each test has one global data sheet that is accessible across actions.

Below is the script to search a specific keyword from Google search:

We are searching for the keyword “automationtutorial.com” in line 1. We also want to search for other keywords. The best approach is to parameterize the search keyword “automationtutorial.com” so that for different executions it has different keywords to search.

Data Table Parameterization from Global Sheet –

Step 1. From Keyword view, select the cell which contains “Atomationtutorial.com” and click on arrow symbol.

Step 2. Value Configuration Dialog box will open as shown below. Select the parameter as Data Table, Enter Name as SearchKeyword, Sheet as Global Sheet and click OK button.

Step 3. New Column SearchKeyword will be created in Global sheet. Add keywords to search in this column.

Step4. Click Run button, you can see that test runs 3 iteration and each iteration uses one keyword from the above list.

Step 5. Global sheet setting can be controlled from “File > Setting > Run” dialog.

Data Table Parameterization from Action Sheet –

Step 1. From Keyword view, select the cell which contains “Atomationtutorial.com” and click on arrow symbol.

Step 2. Value Configuration Dialog box will open as shown below. Select the parameter as Data Table, Sheet as Local Sheet and click OK button

Step 3. New Column SearchKeyword will be created in Local sheet. Add keywords to search in this column.

Step4. Click Run button and observe that script searches only for first keyword because iteration setting of action points to Run One Iteration Only by default.

Step 5. Action setting can be controlled from right click on action in test flow, Properties option will shown as below, select Action Call Properties from the menu.
Step 5. Action call properties dialog box will open as show below. Update the setting and Click Ok.

Test/Action Parameterization

Test/Action parameters enable you to use values passed from calling action to calling action.

Steps to using Test/Action Parameterization

Step 1. Right Click on action node. Properties option will shown as below, select Action Properties from the menu.

Step 2. The Action Properties dialog box will appear. Select Parameters >Input Parameters and click + and add searchkeyword as parameter and type is string. Click OK.

Step 3. Now your action is ready with one parameter searchkeyword. You must use input parameters in the script.

Step 4.  From Keyword view, select the cell which contains “Atomationtutorial.com” and click on arrow symbol.

Step 5. Value Configuration Dialog box will open as shown below. Select the parameter as Test/action parameter and parameter name as searchkeyword .

Step 6. Now the action with parameter is ready to use by any calling action.

Step 7. Now you can call this action in other action by calling action.

RunAction “Action1” oneIteration

Step 8. Right click on Action1 node and select Action call properties. Action call properties dialog box will display. Select the Parameter Values tab and enter searchkeyword value and click OK.

Random Number Parameterization

Random number parameterization Enable you to insert random numbers as values in your test.

Steps to using Random Number Parameterization

Step 1.  From Keyword view, select the cell which required random number and click on arrow symbol.

Step 2. Value Configuration Dialog box will open as shown below. Select the parameter as Random Number.

Step 3. Following options are available for configuring random number parameters:

  • Numeric range
  • Name
  • Generate NEW random NUMBER :
    For each action iteration
    For each test iteration
    Once per entire test run

Step 4. Select appropriate setting and click OK.

Environment Variable Parameterization

Environment variable parameters enable you to use variable values from environment variables.

Types of environment variable 

  • Built in : Environment Variable that represent information about test and the computer.
  • User-Defined Internal: Environment  Variable that you define within test.
  • User-Defined External: Environment Variables present in the external XML file.

Steps to using Environment Variable Parameterization

Step 1. From Keyword view, select the cell which requires parameterization and click on arrow symbol.

Step 2. Value Configuration Dialog box will open as shown below. Select the parameter as Environment.

Step 3. Select the Name of Environment variable and click OK.

Step4. Click Run button and observe that the value in the test has been replaced with environment variable value.

Create External Environment Variable file –

Step 1: Create an xml file using the editor as per your choice

Step 2:Type <Environment> on the first line

Step 3:Type each variable name-value pair within <Variable> elements.

Step 4:Type </Environment> on the last line.

Step 5:Save the file in your computer. Example

<Environment>

<Variable>

<Name>Name</Name>

<Value>Automation</Value>

</Variable>

<Variable>

<Name>Address</Name>

<Value>New Delhi</Value>

</Variable>

</Environment>

Steps to using external environment variable file

Step 1. Select File > Setting to open the test setting dialog box.

Step 2. Click the Environment node

Step 3. Select User-Defined from the variable type list

Step 4. Select the Load variables and values from the external file check box.

Step 5. Use the Browse button and select the xml file which you want to add. The variable defined in the selected file are displayed in blue in the list of user-defined environment variables.

Leave a Reply Cancel reply