Hi I am sorry to open a new topic for this problem, but we were not getting any reply for the old post opened by Ms. Shilpa.
Guys, I need to click on a check box inside an ultragrid, but I am unable to check it.
I have tried SetCellData, i have also tried to select the cell and sending Space keys using WScript.Shell, but even that doesn't work for me.
Could you pelase give us a workaround, as I am stuck at this point.
Please its very urgent for me.
Hello,
Actually we prefer people to start a new topic, as it allows us to tailor the answer to their specific needs, because while the behavior may seem identical, in many cases they may not be. SetCellData should work for all but edge cases of grid checkboxes. So I think we need to determine why your may not be working.
First, what version of NetAdvantage, and TestAdvantage are you using? Both of which are represented by a year, and volume number between 1 to 3. (ie NetAdvantage 2008 Volume 2) QuickTest Professional does not work well against NetAdvantage controls without TestAdvantage and TestAdvantage needs to be the same release volume as the NetAdvantage it is being used against.
Second, what is the recorded action line in QuickTest Professional when you check the checkbox?
If you are getting an error in either record or replay, what is the text of the error, and when does the error get displayed?
Hi Michael,I am using QTP 9.5, Test Advantage - 8.1 CLR 2.0(2008 vol1, clr 2), NetAdvantage - Version 8.1In Recording mode SetCellData gets recorded but when I try to run the same, it throws - Error Message: Specified cast is not valid.
Thansk,
Amit
Hi Amit,
Specified cast is not valid, basically means that the value being sent is not the data type the column is expecting. Which seems odd because the record of SetCellData specifically get the value and not the DisplayText. The two questions this scenario begs to ask are:
What are the exact values that they are recording? (ie "True", True, 1, etc...)
What are the values that the column expects? This is something you may need to ask your developer, but the below snippet should be able to help you garner the information by yourself.
Set grid = SwfWindow("Root").SwfWindow("BaseTest").SwfTable("ultraGrid1")dataTypes = ""bandCount = grid.GetNAProperty("DisplayLayout.Bands.Count")
For x = 0 to bandCount - 1 columnCount = grid.GetNAProperty("DisplayLayout.Bands["+CSTR(x)+"].Columns.Count") dataTypes = dataTypes + "Band - " + CSTR(x) + vbCRLF For y = 0 to columnCount - 1 colName = grid.GetNAProperty("DisplayLayout.Bands["+CSTR(x)+"].Columns["+CSTR(y)+"].Key") dataType = grid.GetNAProperty("DisplayLayout.Bands["+CSTR(x)+"].Columns["+CSTR(y)+"].DataType.FullName") dataTypes = dataTypes + vbTab + "Column [" +colName + "] - " + dataType + vbCRLF NextNext
MsgBox dataTypes
Let me know if this helps,
Hi Michael,
I am sorry for the delay, I was on a trip so couldn't get the chance to reply.
Michael the datatype is Boolean.
I will post more details that ou asked later today sometime. thanks for your help.
I ran the code procided by you, here is the output for required column;
Column [IsPartOf] - System.Boolean
so, even though the datatype is boolean, the setdata gets recorded as string:
SwfWindow("Search").SwfWindow("Adjustment for").SwfTable("ultraGrid").SetCellData "1","IsPartOf","True"
Could you plese advise me, what am I supposed to do?
Thanks Michael
I think you would be best served working with one of our Developer Support Engineers, as they would be able to look deeper into this issue than I could through this forum. I will forward this onto them for you and they should contact you directly in one business day.
Thanks for all your help, I have tried setting the cell data using: True, "True"
but still I am receiving the same error:
Error Message: Specified cast is not valid.
The error is coming at
Infragistics.Win.UltraWinGrid.UltraGrid.OnBeforeCellUpdate(BeforeCellUpdateEventArgs e)
Code Used:
SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").ActivateRow "2"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SelectRow "2"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").ActivateCell "2","IsPartOf"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SelectMultiple "","",""SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SetCellData "2","IsPartOf","True"
And
SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").ActivateRow "2"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SelectRow "2"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").ActivateCell "2","IsPartOf"SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SelectMultiple "","",""SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SetCellData "2","IsPartOf",True
SwfWindow("Search").SwfWindow("Adjustment").SwfTable("ultraGrid_2").SetCellData "2","IsPartOf","True"
I believe there may be something else that I am missing, as I just tested a normal checkbox with a Boolean column, and it works fine with a string value of both "True" and "False". So I am not sure what you are hitting specifically. But I would suggest that you try removing the quotes, around "True" and "False", and just send in the Boolean values of True and False. Let me know if that works for you.