Sunday, June 15, 2008

QTP Tutorials 11 - Actions

In this tutorial we will see how to use more than one action in a test and how to call one action from another with in the same test.


Open a blank test. By default it will have Action1 in it (make sure you are in the keyboard view).


Make sure that Action1 is selected/highlighted and click on the Expert View tab.


In the Expert View type:
msgbox ("my action 1")


Again when you go to keyword View and expand Action1 it will show you function call under it.


In that keyword View itself go to Insert (Menu) ->Call to New Action. 'Insert Call to New Action' Dialog box opens with Action2 as a default name of a new action. By default it will be added at the end of the test as this radio button is selected in the location area.


Click ok.


It will add Action2 to your test.


Make sure that Action2 is selected and click on the Expert View tab.


In the Expert View type:
msgbox ("my action 2")


Similarly insert a third Action.


After third action is added, select Action1(keyword view), right click on it and choose 'Action Properties'.


In the Action properties window that opens, check the 'Reusable action' checkbox at the bottom.


Click ok.


Now again highlight Action3 right click on it and choose 'Insert Call to Existing action'.


'Select action' dialog box appears. In this dialog box in the 'action' dropdown box it will have Action1 by default since we made only that action as reusable.

Just click ok.


In the keyword View where you can see all the three actions, make sure against Action3 it shows "Call to Action1 action" under Documentation.


Run the test. Three message boxes appear in succession showing 'my action 1', 'my action 2', and again 'my action 1'.


0 comments: