Rules for Mapping Custom Actions
- The parameter types supported by Qualitia QTP / UFT are String, integer, and Array.
- Error Resume Next Statement
Add the On Error Resume Next statement at the beginning of the function and the On Error Goto 0 statement before the function end.
For Example,
Function Test()
On Error Resume Next
On Error Goto 0
End Function
- Execution Report Value
All custom actions shall return following integer values only as shown in the following table.
Return | Description |
---|---|
0 | For passed test cases |
1 | For failed test cases |
2 | For defective test cases |
No two custom actions can have the same function name in the same class.
Once the custom action is mapped into Qualitia and used in a test case, do not change the existing signature or other details of the action. The logic of the action can be modified. Also do not delete the action that has been used in the Test Case.
- Add the following block to report the function execution status back to Qualitia Report
For example,
If err.number = 0 Then
WaitFor = 0
WriteStatusToLogs "Action: "&strMethod&vbtab&_
"Status: Passed " &Vbtab&_
"Message: Waited successfully for "&intWaitTime&" secs"
Else
WaitFor = 1
WriteStatusToLogs "Action: "&strMethod&vbtab&_
"Status: Failed" &Vbtab&_
"Message: An error occurred during the wait"
End If
Assign the execution report value as Pass or Fail to the function. In Qualitia, 0 defines as Passed, 1 as Failed and 2 as Defect. We can also assign the value using variables ‘STATUS_PASSED’, ‘STATUS_FAILED’ and ‘STATUS_DEFECT’. The WriteStatusToLogs is used to display the message in Qualitia execution report.
- Return a Value or Store a Value in a Variable
To return a value/store a value in variable from custom action, we need to use the following code:
For example, AddItemToStorageDictionary strKey, strValue
The required value, strValue will be stored in the variables strKey and it can be used across the test case to retrieve the variable value.
- Using or Passing integer values in Qualitia
To use any value as an integer inside the custom action, make sure to use Cint() and specify the data type as String while mapping the custom action in QFD.