We have an application that has a group details form with three tabs that each contain a simple UltraGrid. I have an action in my test that clicks on each tab and (among other things) restores the default layout for the grid. When I run the entire action, it performs the Restore Default Layout on the first tab, but I get either a "General Run Error" or a "Key Not Found" error when it tries to restore the default layout on the subsequent tabs (I close the group details form and reopen it after performing the various checks on each tab).
Here is a sample of the code as recorded by QTP (the test fails on the Select "Restore Default Layout" line):
SwfWindow("Company Name").SwfWindow("GroupDetails").SwfTable("ultraGrid1").RightClick "0","0;GroupName"SwfWindow("Company Name").SwfWindow("GroupDetails").SwfTable("ultraGrid1").SelectMultiple "","",""SwfWindow("Company Name").SwfWindow("GroupDetails").SwfTable("ultraGrid1").ActivateRow "0"SwfWindow("Company Name").SwfWindow("GroupDetails").SwfTable("ultraGrid1").SelectRow "0"SwfWindow("Company Name").SwfWindow("GroupDetails").SwfWindow("SwfWindow").SwfToolbar("SwfToolbar").Select "Restore Default Layout"
If I run QTP from step and only execute the steps for each particular tab, the portion of the code for each individual tab can be executed without error. I've tried adding a Wait statement at various points, but it doesn't help.
I'm using QTP 9.2 with TestAdvantage 2006 v2 CLR 1.x, so any help someone could provide will be appreciated!
Dennis,
I'm glad my post helped. and thanks for the follow up in case someone else run into the same issue.
Ammar
Hi Ammar,
It took some experimentation, but I got your solution to work. In case anyone else encounters a similar problem, they may have to change the value of several properties (as opposed to a single property) for the first grid test object before QTP is forced to add a different test object for additional controls. Also, it might be easier to "fool" QTP while recording a new action, rather than an existing action, depending on the complexity of the action and your degree of familiarity with the Object Repository (I'm still learning about the OR myself).
Anyway, thank you for your help!
Dennis
The reason could be that to QTP both grid are mapped to one TestObject (SwfTable("ultraGrid1")) while in reality they are two different control.
So I think what is happening is that QTP try to act on the first grid all the time (which I think does not have a column named "Home_Branch_ID" so during replay it complains about the column key not found.
I've read a post on QTP forums on how to force QTP to add different test object for different control. Simply you record on the first control, Stop recording open the object repository and change the value of any property for the grid test object, Close the OR and save your script (Saving the test is important and without it the trick does not work) Then start recording again and do something on the second grid (this will force QTP to add a new Test object for the second gid) Stop recording and open OR again and re-update the property value that you have changed before and set it back to its original value.
now you should have two test object so your script should look like this (Note the diiferent test object name for the second grid)
Tab A: (Restore Default Layout)SwfWindow("Company").SwfWindow("GroupDetails").SwfTable("ultraGrid1").RightClick "0","0;PointName"SwfWindow("Company").SwfWindow("GroupDetails").SwfWindow("SwfWindow").SwfToolbar("SwfToolbar").Select "Restore Default Layout"
Tab B: (Group/Upgroup rows by a column)SwfWindow("Company").SwfWindow("GroupDetails").SwfTable("ultraGrid1_1").SetGroupByColumns "0:Home_Branch_ID"SwfWindow("Company").SwfWindow("GroupDetails").SwfTable("ultraGrid1_1").SetGroupByColumns ""
I hope this will help.
Regards,
Thank you for your reply. Removing the lines you suggested seemed to have eliminate the General Run Errors, but I'm still getting a "Key Not Found" error. I've done some additional research and learned from one of our developers that the grid is named the same on each tab, so could that be the problem? In other words, could QTP be getting confused as to which grid it's actually on at a particular moment?
If that's the case, how can I further differentiate between two or more grids? The regular Object Spy reveals the following hierarchy for each grid, with the differences underlined:
Tab A: SwfWindow: Company > SwfWindow: Group Details > SwfTab: groupDetailsTabControl > SwfObject: pointsTabPage > SwfObject: assignSecurityPointsUC > SwfObject: pointsCompanyGrid > SwfObject: gridPanel > SwfTable: ultraGrid1
Tab B: SwfWindow: Company > SwfWindow: Group Details > SwfTab: groupDetailsTabControl > SwfObject: usersTabPage > SwfObject: Panel6 > SwfObject: usersCompanyGrid > SwfObject: gridPanel > SwfTable: ultraGrid1
Following is some example code that was recorded on each tab. The "Key Not Found" error occurs when the test reaches the "SetGroupByColumns "0:Home_Branch_ID" line.
Tab B: (Group/Upgroup rows by a column)SwfWindow("Company").SwfWindow("GroupDetails").SwfTable("ultraGrid1").SetGroupByColumns "0:Home_Branch_ID"SwfWindow("Company").SwfWindow("GroupDetails").SwfTable("ultraGrid1").SetGroupByColumns ""
Thanks in advance for any help you can provide!
Hi Dennis,
It seems that the "Select" action is recorded when you click on the context menu. Try removing the 3 actions between RightClick and Select so have you script looks like this
SwfWindow("Company Name").SwfWindow("GroupDetails").SwfTable("ultraGrid1").RightClick "0","0;GroupName"SwfWindow("Company Name").SwfWindow("GroupDetails").SwfWindow("SwfWindow").SwfToolbar("SwfToolbar").Select "Restore Default Layout"
The 3 removed action are not required but they get recorded because of the way the grid response to a right click, and since we are replaying the right click then we don't need those other actions. You may come across this in other scenarios and other controls. Look for action that you did not perform during record and remove them.
I hope that will work