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:
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
To nest an action within an existing action:
- Highlight the step after which you would like to insert the call to the action.
- 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