You can specify input parameters for an action so that steps in the action can use values supplied from elsewhere in the test. Input values for an action parameter can be retrieved from the test (for a top-level action) or from the parameters of the parent action that calls it (for a nested action), or from the output of a previous action call (for a sibling action).
You can specify output parameters for an action, so that it can return values for use later in the test. For example, you can output a parameter value to a parent action so that a later nested action can use the value.
For each input or output action parameter, you define a name (case sensitive), a type, and optionally, a description. You can also specify a default value for each action input parameter, or you can use the default value that QTP provides for the parameter value type that you choose. The default value is saved with the action and is used by the action if a value is not defined for a parameter in the action call. You can define, modify, and delete input and output parameters in the Parameters tab of the Action Properties dialog box (Edit > Action > Action Properties or right-click an action and select Action Properties).
To add a new input or output action parameter:
- Click the Add button above the Input parameters or Output parameters lists to add a new parameter to the appropriate list. A row for the new parameter is added to the relevant list.
- Click in the Name box and enter a name for the parameter. (Action parameter names are case sensitive.)
- Select the value type for the parameter in the Type box. You can select one of the following types:
- String. A character string enclosed within a pair of quotation marks, for example, "New York". If you enter a value and do not include the quotation marks, QTP adds them automatically when the value is inserted in the script during the test run. The default value is an empty string.
- Boolean. A true or false value. If you select a Boolean value type, you can click in the Default Value column and click the arrow to select a True or False value. The default value is True.
- Date. A date string, for example, 3/2/2005. If you select a Date value type, you can click in the Default Value column and click the arrow to open a calendar from which you can select a date. The default value is today's date.
- Number. Any number. The default value is 0.
- Password. An encrypted password value. If you select a Password value type, the password characters are masked when you enter the password in the Default Value field. In the action, however, the value appears encrypted. The default value is an empty string, which also appears as an encrypted value in the actual action.
- Any. A variant value type, which accepts any of the above value types. Note that if you select the Any value type, you must specify the value in the format that is required in the location where you intend to use the value. For example, if you intend to use the value later as a string, you must enclose it in quotation marks. When you specify a value of Any type, QTP checks whether it is a number. If the value is not a number, QTP automatically encloses it in quotation marks. If you are editing an existing value, QTP automatically encloses it in quotation marks if the previous value had quotation marks. The default value is an empty string.
- If you are defining an input action parameter, click in the Default Value box and enter a default value for the parameter. Alternatively, you can leave the default value provided by QTP for the parameter value type. The default value is required so that you can run the action without receiving parameter values from elsewhere in the test.
- (Optional) Click in the Description box and enter a description of the parameter, for example, the purpose of the parameter in the action. QTP displays this description together with the name of the parameter in any dialog box in which you can choose an action parameter, including the Output Options, Parameter Options, and Value Configuration Options dialog boxes. To modify an existing action parameter:
- Select the parameter you want to modify from the Input parameters or Output parameters list.
- Modify the values as necessary in the edit boxes of the parameter row. To delete an existing action parameter:
- Select the parameter you want to delete from the Input parameters or Output parameters list.
- Click the Delete button. The parameter is removed from the list.
Note: When you delete an action parameter, make sure that you also delete any steps that use the action parameter.
Post a Comment