Updating ActiveX Datagrids in QTP

By XeroCube | July 11, 2008

In my recent testing efforts, I have comes across a desktop windows form (written in VB6) involving updating a data grid and then calculating another field’s value based on those updates. In order to achieve this functionality, the development staffs implemented two events (AfterColUpdate and LostFocus) that, when triggered, would fire off the calculation method.

None of this is obvious to the end user when testing, all they see is enter a number into the grid column and the total field automatically updates with the sum of all values in the column. Easy peasy.

I created my reusuable action in QuickTest Pro and record the entering of data, which yielded the following code:

VbWindow(“frmMain”).VbWindow(“frmChildWindow1”).VbWindow(“frmChildWindow2”).AcxTable(“PaymentGrid”).SelectCell 1,4

VbWindow(“frmMain”).VbWindow(“frmChildWindow1”).VbWindow(“frmChildWindow2”).AcxTable(“PaymentGrid”).SetCellData 1,4, “30.00”

When recording this functionality, the application behaved as expected. The total field was calculated. However, upon playing this code back, only the data grid column value was updated. This brings us back to the solution explained above. QTP only posted the value, but didn’t fire off the LostFocus or AfterColUpdate events.

After some research and time spent exploring options in the AcxTable(“PaymentGrid”.object intellisense menu, I found the method that solved my issue.

VbWindow(“frmMain”).VbWindow(“frmChildWindow1”).VbWindow(“frmChildWindow2”).AcxTable(“PaymentGrid”).Object.Update

This method call fires off all events triggered by updating the data in the grid. Who’d have thought that?

Hope this saves someone the time and trouble it took me to discover this simple issue.

Topics: Quality Assurance, QuickTest Pro, VBScript | No Comments »

Comments

Archives

Blogroll

RockinMedia