| || |
Question about iterations
The application I am working on has an equipment maintenance status feature. The user can submit status reports whenever there is a problem with any organizational equipment.
The form for this report has several fields, three of which are drop down menus for the Location, Equipment Type and Sub-component. The last two drop down menus are dynamically populated based on the option selected in the previous menu. For example, the Location option you select populates the Equipment Type drop down menu (different types of equipment at each location). The Equipment Type option you select determines what options are available in the Sub-component menu (different equipment types have their own unique list of sub-components).
I am trying to create a script that executes 100% path coverage of all the permutations of the three drop down menus. For example, iteration 1 selects Location 1, Equipment Type 1, Subcomponent 1. Iteration 2 selects Location 1, Equipment Type 1, Subcomponent 2. All subcomponents for Equipment type 1 would be executed before progressing to Equipment type 2. All Equipment Type options would be executed before progressing to Location 2.
Is a parameterized script like this possible to create? If so, I assume it will require nested actions and conditional statements, which I haven't used before in any of my QTP scripts. If anyone can provide a pointer on how I should set this up I would appreciate it.
EDIT: changed the Subject to reflect the issue discussed in my reply below.
[ 05-19-2004, 07:36 AM: Message edited by: TReece ]
Re: Question about iterations
I don't see any reason for nested actions, I suggest that you use a simple Select Case
Re: Question about iterations
Based on the suggestion above, I used a Select Case statement for my script. The script only tests two of the dynamic drop menus, not three like I mentioned in the original post. For the Location drop down menu, I used the same value for the entire test. I still encountered a problem though related to how QTP iterates the test based on the Global and Local datatable.
For the Equipment Type drop down menu, I parameterized those values in the Global datatable. For the Sub-component drop down menu, I parameterized those values in the Local Action datatable. I have 5 different Equipment Type parameters in the Global datatable. As a result, there are five columns in the Local datatable. Each column in the Local datatable contains all the sub-components for each different type of equipment. The number of rows in each column of the Local datatable are different, i.e Equipment Type 1 has 5 sub-components, while Equipment Type 2 has 7 sub-components.
When I run the test, it starts with the first parameter (Equipment Type 1)in the Global datatable and then iterates successfully 5 times, each iteration using a different parameter from Equipment Type 1 sub-component column. After the fifth iteration, instead of progressing to the second parameter in the Global action sheet, it tries to iterate a 6th time. This time it is looking for a parameter in the 6th row of the Local Action sheet. The test fails since there is no parameter in the 6th row of the Equipment Type 1 sub-component column. I think because one of the columns in the Local datatable has 7 rows (Equipment Type 2), QTP by default tries to iterate 7 times for each parameter in the Global action datatable. I know this can be resolved by using some form of conditional statement, but not certain what approach to take. I got it to work by using a workaround. For the columns in the Local datatable that have less than 7 parameters, I duplicated one of the existing parameters to bring each column in the Local datatable up to 7 rows.
Once I made this change, the script will successfully iterate 35 times (5 global parameters * 7 rows for each column in the Local datatable). Now I run into a second problem. Instead of ending the test after 35 iterations, the script continues and tries to iterate for a 6th round. Because there are only 5 parameters in the Global datatable, the test fails when it tries to find a value in the 6th row of the Global datatable. I assume since there are 7 rows in each column of the Local datatable, QTP assumes there will be 7 rows in the Global datatable. I can probably use the same workaround to get the test to execute successfully, but I would prefer to learn how to use conditional statements to make the script work.
I have all the QTP manuals and the examples they provide for conditional statements is lacking. So any suggestions are appreciated.