Pages

Monday, June 6

Utility Statements in QTP - Part 2

Hey Friends!

In this part of post, we will discuss various exit statments in QTP. Following are the names of exit statements provided in QTP to exit from Test/Action/Iterations. Let's check it out..

ExitAction Statement
ExitActionIteration Statement
ExitComponent Statement
ExitComponentIteration Statement
ExitTest Statement
ExitTestIteration Statement


Assume that you have a QTP Test (MyTest), containing two actions (one_Action and Two_Action) it it. Now let's see how we can use different exit statements.


ExitAction Statement

As the name suggests, 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.

Syntax:

Print "Before Exit"
ExitAction 'without any spaces
Print "After Exit"

In above example, only first line will be printed. After printing this line, action will be terminated and next action will start (If Any).

Please note that..

1. The ExitAction statement and its return value are displayed in the Test Results.
2. The pass or fail status of the action remains same as it was in the step prior to the ExitAction statement.


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.


Syntax:

empName = DataTable("Name", dtLocalSheet)
If empName = "Abhikansh" Then ExitActionIteration("exit iteration")


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.


ExitComponentIteration Statement

ExitComponentIteration is similar to ExitComponent, only difference is that it exits the current iteration only, not component.


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.


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.