In this series of post, we’ll discuss the utility statements. These are very useful commands, provided in QTP, make your life easy.
The following utility statements help you control your test.
- DescribeResult Statement
- ExecuteFile Statement
- ExitAction Statement
- ExitActionIteration Statement
- ExitComponent Statement
- ExitComponentIteration Statement
- ExitTest Statement
- ExitTestIteration Statement
- GetLastError Statement
- InvokeApplication Statement
- ManualStep Statement
- Print Statement
- RegisterUserFunc Statement
- RunAction Statement
- SetLastError Statement
- UnregisterUserFunc Statement
- Wait Statement
DescribeResult Statement
DescribeResult returns a text description of the specified error code. In following code, error is retrieved using the ‘GetLastError’ statement, and then the DescribeResult statement is used to print the text description of the error code.
Browser(“mybrowser”).Page(“mypage”).Image(“myimage”).Click 23, 47
errX = GetLastError
print (DescribeResult(errX))
ExecuteFile Statement
ExecuteFile Statement is used to execute the VBScript statements in the specified file. It is an alternative of associating a file to your test. Once the file runs, the definitions (functions, subroutines, classes, etc.) in the file are available from the global scope of the action’s script.
ExecuteFile “C:abcMyFunctionLib.vbs”
Once done, all the function/code in the file will be avialable to use.
Please note that if are using ExecuteFile instead of associating it with test, you cannot debug a file/using breakpoints.
Related Posts:
Utility Statements in QTP – Part 2
Utility Statements in QTP – Part 3
I have a file that I need to copy from a source destination that is going to be dynamic to the local destination.