How do I get QTP to record clicking on a tri-state ImageCheckBox in an UltraGrid? QTP activates and selects the cell, but it does not recognize the actual "checking" (or unchecking) of the checkbox. Here are the lines of code that QTP records:
SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").ActivateRow "0"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").ActivateCell "0","ImageCheckBox"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").SelectCell "0","ImageCheckBox"
I'm using QTP 9.2 with TestAdvantage 2006 v2 CLR 1.x, so any help will be appreciated!
Due to timing issues, Checkbox based columns may not record as you might expect, cell changes record when the cell updates. Which cell's update when they lose focus. Now you might think this is incorrect, but if you put it in respects to a text based column, where you might type in a long string of characters you don't want it to record each individual change/key stroke, as it would record excessive amount of unneccesary lines of code. So it waits until you attempt to leave the cell, and records a SetCellData if the data updates correctly, or SetInvalidDataCell if it triggers a CellDataError. Try after checking the checkbox, clicking anywhere else or pressing TAB, to give focus to something else.
Let me know how this works for you.
Hi Mike and Ammar,
Thank you for your replies. I've tried implementing your suggestions, but my initial efforts have not proven to be successful. The tri-state checkbox does not appear to have a corresponding keyboard simulation, such as using the spacebar, like a regular checkbox, while using SetCellData and clicking or tabbing out of the cell/row does not "check" the checkbox either.
Following further discussions with our developers, I've learned that the value for the "ImageCheckBox" column is actually set in a hidden column called "ImageCheckBoxValue" and the possible values are 1 = "Checked" (Approved), 0 = "X" (Denied) and 2 = "Blank" (Null). I've tried using SetCellData on the "ImageCheckBoxValue" cell (and the "ImageCheckBox" cell), but QTP returns the following error in the Test Results: "ultraGrid1.SetCellData: {184, ImageCheckBoxValue} cell is not editable". I used "GetNAProperty("ActiveCell.Column.CellActivation")" on the cell and it returns a zero, which is AllowEdit, so apparently I'm not doing something correctly.
Following is an example of my revised code for the "ImageCheckBoxValue" cell:
SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").ActivateRow "184"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").ActivateCell "184","ImageCheckBoxValue"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").SelectCell "184","ImageCheckBoxValue"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").SetCellData "184","ImageCheckBoxValue","1"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").ActivateRow "185"SwfWindow("Company").SwfWindow("Group Details").SwfTable("ultraGrid1").SelectRow "185"
Any additional insight you guys can give me will be appreciated!