QTP10.com is a new and completely free website that offers help in all the versions of HP QTP (including latest version 10). More importantly, it offers free code for users of HP QuickTest Professioal. This site helps you in learning the basics of QTP and descriptive/advanced programming in (QTP) on various environments like - .Net, Infragistics, Web, Windows, etc.

Note -
This blog is NOT affiliated with HP / Hewlett-Packard in any way. The data/questions come from various sources and we have our own testing questions. I am just another Software Tester like you.

Nesting Actions in QTP

Share This Post -

Sponsored Links:

Sometimes you may want to call an action from within an action. This is called nesting. By nesting actions, you can:

  • Maintain the modularity of your test.
  • Run one or more actions based on the results of a conditional statement.

For example, suppose you have parameterized a step where a user selects one of three membership types as part of a registration process. When the user selects a membership type, the page that opens depends on the membership type selected in the previous page. You can create one action for each type of membership. Then you can use If statements to determine which membership type was selected in a particular iteration of the test and run the appropriate action for that selection.

In the Keyword View, your test might look something like this:


Nested Actions


In the Expert View, your test might look something like this:

Browser("Membership Preference").Page("Membership Preference").WebRadioGroup("MemType").Select DataTable("memtype", dtGlobalSheet)

Mem_Type=Browser("Membership Preference").Page("Membership Preference").WebRadioGroup("MemType").GetROProperty ("value")

If Mem_Type="paid" Then

       RunAction "Paid_Mem", oneIteration

ElseIf Mem_Type = "free" Then

       RunAction "Free_Mem", oneIteration


       RunAction "Preferred", oneIteration

End If


To nest an action within an existing action:

  1. Highlight the step after which you would like to insert the call to the action.
  2. Follow the instructions for inserting a call to a new action as described in Creating New Actions.

Go Back to: Working with Actions in QTP