Guys,
Here some useful utility statement m going to cover.
Here some useful utility statement m going to cover.
Sr No
|
Utility Statement
|
Description
|
Example
|
1
|
DescribeResult Statement
|
DescribeResult returns a text description of the specified error
code.
|
Browser("mybrowser").Page("mypage").Image("myimage").Click
23, 47
errX = GetLastError print (DescribeResult(errX)) |
2
|
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
Please note that if are using ExecuteFile instead of associating it with test, you cannot debug a file/using breakpoints. |
ExecuteFile "C:\abc\MyFunctionLib.vbs"
|
3
|
ExitAction Statement
|
ExitAction simply exits from the current running action.
If you use ExitAction statement in One_Action, it will immediately exit from this action and your next action will start executing |
Print "Before Exit"
ExitAction 'without any spaces Print "After Exit" |
4
|
ExitActionIteration Statement
|
Suppose you are set to run two iteration of each action in the
test, by providing two rows of data in datatable. Now you want to exit
current iteration if
data in the table is not matching or something like that. We can do it using ExitActionIteration. Its similar to ExitAction, only difference is that it exits the current iteration only, not action |
empName = DataTable("Name", dtLocalSheet)
If empName = "Abhikansh" Then ExitActionIteration("exit iteration") |
5
|
ExitComponent Statement
|
ExitComponent statement is used in Business Process Testing
(BPT) using Quality Center(QC). It exits the current component run.
- If the component is not part of a component group, then any remaining component iterations are skipped and the run proceeds to the next component in the test. - If the component is part of a component group, then the entire component group is skipped and the run proceeds to the next component after the component group. - The pass or fail status of the component remains as it was in the step prior to the ExitComponent statement |
|
6
|
ExitComponentIteration Statement
|
ExitComponentIteration is similar to ExitComponent, only
difference is that it exits the current iteration only, not component.
|
|
7
|
ExitTest Statement
|
ExitTest exits from current test without proceeding to the next
actions. The execution will be stopped from the point you use ExitTest
statement.
|
|
8
|
ExitTestIteration Statement
|
ExitTestIteration Statement exits the current iteration of the
QuickTest test or Quality Center business process test and proceeds to the
next iteration, or exits the test run if there are no additional run-time
parameter iterations. The pass or fail status of the test iteration remains
as it was in the step prior to the ExitTestIteration statement
|
|
9
|
GetLastError Statement
|
GetLastError returns the error code of the last/most recent
error. It is used with the DescribeResult Statement
|
Browser("mybrowser").Page("mypage").Image("myimage").Click
23, 47
errX = GetLastError print (DescribeResult(errX)) |
10
|
InvokeApplication Statement
|
InvokeApplication is used to invoke an executable application
i.e. '.exe' files
|
InvokeApplication "C:\Program Files\Internet
Explorer\IEXPLORE.EXE"
|
11
|
ManualStep Statement
|
||
12
|
Print Statement
|
Print is very useful and simple to use statement, generally used
in place of 'msgbox'. It displays information in the QuickTest Print Log
window during the
run session. The log window remains open until you close it manually |
Print "This is an example"
Print Browser("MyBro").GetROProperty("title") |
13
|
RegisterUserFunc Statement
|
Using RegisterUserFunc, you can add a new method or can override
the existing method of any test object class.
For example, 'Set' is a method of WebEdit class, which sets value in the edit box. Using RegisterUserFunc, you can change the behaviour of this method or you can add new method to WebEdit class 1.Registered method applies only to the test or library file in which you register it. 2. It is applicable to current run session only. 3. QuickTest clears all function registrations at the beginning of each run session. |
Function NewSet (obj, val)
Dim MyWord MyWord = UCase(val) ' Returns val in upper case MySet=obj.Set(val) End Function RegisterUserFunc "WebEdit", "Set", "NewSet" Browser("MyBro").Page("MyPage").WebEdit("name").Set "abhikansh" UnRegisterUserFunc "WebEdit", "Set" |
14
|
RunAction Statement
|
The RunAction statement runs the specified action (if associated
with your test).
If you want to run external action, which is not associated with your test, then you have to use (Insert > Call to Action) or (Insert > Copy of Action) options from QTP menu. |
RunAction "Action2", oneIteration
|
15
|
SetLastError Statement
|
Inserts a VBScript error into the test script
|
SetLastError(7)
|
16
|
UnregisterUserFunc Statement
|
instructs QuickTests to stop using the current registration of
the method
|
|
17
|
Wait Statement
|
Wait is one of the most commonly used utility statement. Used
for a pause of specified seconds, during a run session
|
Wait(10)
|