Hi,
I am having problem with setting cell data inside a grid.
Code generated:
SwfWindow("Window").SwfWindow("Window").SwfTable("Grid").SetCellData "0","HOUSE_NUMBER","D12345"
During payback, the application crashes. Anyone has faced this problem before? Any help is really appreciated
Thanks,
Srini
HouseNumber, what is the datatype for that variable? I would suggest passing it in as CStr(HouseNumber) for the purpose of SetInvalidDataCell as SetInvalidDataCell requires that the last paramater be a string.
Also what is the StackTrace for the new "Object reference not set to an instance of an object." exception?
Hi Michael,
I tried using SetInvalidDataCell and received run time error “Object reference not set to an instance of an object” at third line. My Application is not crashing anymoreJ
When i made some changes (check modified code below) not getting run time error but QTP is NOT setting value and just goes to the next iteration without failing
Modified Code:
SwfWindow("Window").SwfWindow("Window").SwfTable("Grid").SelectRow Cint(i)SwfWindow("Window").SwfWindow("Window").SwfTable("Grid").ActivateCell Cint(i),"HOUSE_NUMBER"SwfWindow("Window").SwfWindow("Window").SwfTable("Grid").SelectMultiple "","",""SwfWindow("Window").SwfWindow("Window").SwfTable("Grid").SetInvalidDataCell Cint(i), "HOUSE_NUMBER", HouseNumber
I really appreciate all your help
Hi Srini,
In looking at the stack trace the exception is being thrown by your application. It's in your applications handling of the BeforeCellUpdate method. Now as to the cause it may be in how we set the data when you use the SetCellData. With that method since the data type can be anything, and as such so can the editor we set the root value of the cell to the string value of the value set. The grid in turn uses internal methods of the editor to automatically cast the value to the correct data type. We then trigger the events OnCellChange and if neccesary OnCellListSelect to make it appear as if it was done via the editor. By looking at the stack trace the error was caused by the setting of the value and happens prior to us manually firing events, so there is no collision on the triggering of the events, and is more likely that the data in that state is not valid for the cell.
Now my thoughts on the cause it can be a few things:
First is the data that you are typing in valid? By typing in an incorrect value, the editor looks at the data and rejects it in a correct manner. By setting the value directly it by passes the editor, and therefore you are directly setting an invalid data type to a cell which can cause an error similar to the one thrown.
Other thoughts on it are if you have either custom editors and/or a custom data type. If either of those were not fully implemented correctly it may trigger similar behavior.
In either of those cases, I would use the action SetInvalidDataCell instead of SetCellData. The reason being is instead of setting the value directly it Enters edit mode and directly types in the value. This of course can only work for cells with text based editor, that accept typed keyboard input. But from what you described that is the case.
Let me know if this helps,
I am using following versions
QTP – 9.2 with .Net Add-in 9.2
NetAdvantage 2007 Vol 1, CLR 2.0 v 7.1.20071.1048
TestAdvantage 2007 Vol 1, CLR 2 v 7.1.20071.10
If I break on replay before the SetCellData, and type in the value listed application does NOT Crash
Following exception is thrown when application crashes
at Infragistics.QTPServer.WinGrid.WinGridRecordReplayServer.fnSetCellData(Object row, Object column, Object strValueobj)
And, I am not sure how to capture the Visual Studio process
From just looking at those two lines of code it's impossible to tell why your application may have crashed. Can you eloborate a bit more on your setup and the error in question.
What version of NetAdvantage is the application using, including CLR?
What version of TestAdvantage are you using with QuickTest Professional, including CLR?
What version of QuickTest Professional are you using?
What if any exception is thrown when your application crashes?
If you break on replay before the SetCellData, and type in the value listed does it crash?
If possible, can you attach a Visual Studio process to the application in question before it crashes, run it, and capture a stack trace of the exception?
These questions will greatly assist me in helping you with this behavior.