Hi,
I am facing a problem in trying to select a checkbox in an ultraWinGrid control (screenshot attached)
The checkbox lies within one of the cells and I am not able to set the checkbox to an On state.
Is there a native method/property which can be used to set the checkbox to a "checked" state?
SwfWindow("xxx").SwfWindow("yyy").SwfTable("zzz").Object.SomeMethod
I'm using QTP 10, Test Advantage 2005 Volume 3 CLR 1.0. Application is coded in c#.
Any help would be appreciated.
Regards,
Chandan
I am uncertain, but I believe you are hitting an issue I addressed a while ago, but unfortunately much later than 2005 Volume 3. When you set the checkbox value, does your application under test (AUT) automatically open a dialog box of somekind? If so, does it hang and eventually crash after checking the checkbox, but prior to clicking the button. If you comment out the button click method, and when it hits that point, you manually click it, does it continue as expected?
If so I believe what is happening is because the act of setting the value opens the dialog box, it is waiting for the grid to have focus before it can properly complete that action. But because the dialog box is open, it hangs. If you click the button, it will hang again, because now it is passed the SetCellData method, but now waiting to push the button, which is no longer visible because it's closed. Both should hang temporarily, but eventually crash the script.
That being said, if this is the scenario, unfortunately 2005 Volume 3 is out of support and we will not be able to fix it. As a work around, albeit not the prettiest, what I would suggest is getting the cell into edit mode, and hitting the spacebar. While there is no direct method in 2005 volume 3 to get a cell with a CheckEditor into editmode, you can do it by activating the cell tabing into it, and out of it, and then pressing the space bar to set the value. This should bypass this issue for you.
To do that you can do the following :
Set Grid = SwfWindow("xxx").SwfWindow("yyy").SwfTable("ultraGrid")
Grid.ActivateCell "6", "SELECTED_COL"Grid.Type micTab + micShiftDwn +micTab + micShiftUp + " "
You cannot set the cell to a specific value this way, only change it. But with GetCellData and an if statement, you can definitively set the value to whatever you want.
Hi Michael,
I'm now able to set the checkbox in the ultrawingrid. But after I check the checkbox and click OK button to close the window, the application is hanging. I tried workarounds like arrow keys / spacebar (to check), used native object.set property. But for all these scenarios, my application is hanging. However, when I check the checkbox manually and click OK button, application does not hang. I thought this could be because the grid might be having some hidden columns whose values are set along with the checkbox. I checked all the hidden columns and the only column that is changing when we check the checkbox is the checkbox column. I also checked if the grid will allow us to edit or not. I have full permission to edit the checkbox. I have pasted the code I have used. Please let me know if I'm missing something:
SwfWindow("xxx").SwfWindow("yyy").SwfTable("ultraGrid").SetCellData "6","SELECTED_COL","True"
SwfWindow("xxx").SwfWindow("yyy").SwfButton("OK").click
Or
Set o = SwfWindow("xx").SwfWindow("yyy").SwfTable("ultraGrid").Object o.rows.Cells["SELECTED_COL"].Value = TrueSet o = Nothing
I executed the following code to ensure that the user is having edit access to edit the grid
SwfWindow("xxx").SwfWindow("yyy").SwfTable("ultraGrid").ActivateCell "5","SELECTED_COL"CellActivation = SwfWindow("xxx").SwfWindow("yyy").SwfTable("ultraGrid").GetNAProperty("ActiveCell.Column.CellActivation")msgbox CellActivation
I'm getting 0 in CellActivation.
Could you please let me know what could be the reason why the application is hanging, only when we perform the action through the QTP script?
I have done this for infragistics ultragrid as follows:
To get status of Checkbox in cell.....SwfTable("").GetCellData(RowNum,ColNum)
It will return TRUE if checked else FALSE
To set status of Checkbox in cell.....SwfTable("").SetCellData(RowNum,ColNum,TRUE/FALSE)
Hope it will help
Hi Chandan,
I am assuming that you have NetAdvantage 2005 Volume 3 CLR 1.0 in your application to match your TestAdvantage 2005 Volume 3 CLR 1.0. That being said, it should record and replay:
SetCellData sRowPath, sColumn, sValue
SwfWindow("xxx").SwfWindow("yyy").SwfTable("zzz").SetCellData "4","checkbox","True"
Note that due to the timing of events particular to Checkboxes in the grid, it will only record after you leave the focus of the cell. IE move to another cell, or control.
If for some reason it doesn't record, you can still try to maunally script it, again using the syntax shown above. Let me know if this works for you.