I'm using QTP 9.2 with TestAdvantage 2006 v2 CLR 1.x and I would like to know how I can determine if a cell in an UltraGrid has a status of "Allow Edit" or "No Edit". Certain cells in the grid of our application should have a status of "Allow Edit" all of the time, while other cells should have a status of "No Edit" only in certain instances, so I'm trying to check those in my test scripts.
I've spied on the grid with the .Net Object Spy and found the following: Display Layout > Bands > 0 > Columns > (Column Name) > Row Layout Column Info > Column > Cell Activation > AllowEdit, which I assume is the property I'm needing, but I'm not sure of the syntax for my test scripts to return that property. Here is an example of my scripts, but I'm obviously doing something wrong as when I message box the second line, I get an empty message:
SwfWindow("Company Name").SwfWindow("Purchase Order for Branch").SwfTable("ultraGrid1").ActivateCell "0","QuantityReceived"
SwfWindow("Company Name").SwfWindow("Purchase Order for Branch").SwfTable("ultraGrid1").GetROProperty ("CellActivation", "AllowEdit")
I've only been using TestAdvantage with QTP for about a year, so any help will be appreciated. Thank you!
Hi Dennis,
Use the following line after "ActivateCell" method call
CellActivation = SwfWindow("Company Name").SwfWindow("Purchase Order for Branch").SwfTable("ultraGrid1").GetNAProperty("ActiveCell.Column.CellActivation")
This return an Enumeration as follow:
AllowEdit = 0,
ActivateOnly = 1,
Disabled = 2,
NoEdit = 3,
Hope that is helpful.
Regards,
Ammar
Hi Ammar,
That worked like a charm. Thank you for your help!
Dennis
In TestAdvantge 2007 Vol 3 this code will work ? if not please provde me piece of code for TD 2007 Vol.3.
We are getting the SwfTable grid data with below code but unfortunalty we unable to select or click that cell or row.
How can i select or click that Cell or row.
Please help in this regard.
msgbox rowCollection.item(iLoop).Cells.Item(2).Text
Next
Hi,
The problem that you are likely facing is the parameters required for the TestAdvantage methods SelectCell and Activate Cell while they are derived from the Row Indexes there is no direct means of generating them. Below are two Functions that you can add, that will take in the cell and row objects and return the arguements neccesary to use inside of most of our UltraGrid functions.
So using your example you can do something like:
Set row = rowCollection.Item(iLoop)
Set cell = row.Cells.Item(2)
SwfWindow("WindowHome").SwfWindow("WindowNew").SwfTable("Element").SelectCell GetRowArg(row), GetCellArg(cell)
Function GetCellArg(cell) GetCellArg = cell.Column.KeyEnd Function
Function GetRowArg(row) rowArg = "" On Error Resume Next Do WHILE NOT IsEmpty(row) SET parentRow = row.ParentRow temp = "" If NOT IsEmpty(parentRow) Then If parentRow.HasChild() Then If parentRow.ChildBands.Count > 1 Then For childBandIndex = 0 to parentRow.ChildBands.Count If parentRow.ChildBands.Item(childBandIndex).Band = row.Band Then temp = CStr(childBandIndex) + "," + CStr(row.Index) Exit For End If Next End if End if End If If temp = "" Then temp = Cstr(row.Index) End If If Len(rowArg) > 0 Then rowArg = temp + ";" + rowArg Else rowArg = temp End If row = parentRow LOOP On Error Goto 0 GetRowArg = rowArgEnd Function
Function GetRowArg(row) rowArg = "" On Error Resume Next Do WHILE NOT IsEmpty(row) SET parentRow = row.ParentRow temp = "" If NOT IsEmpty(parentRow) Then If parentRow.HasChild() Then If parentRow.ChildBands.Count > 1 Then For childBandIndex = 0 to parentRow.ChildBands.Count If parentRow.ChildBands.Item(childBandIndex).Band = row.Band Then temp = CStr(childBandIndex) + "," + CStr(row.Index) Exit For End If Next End if End if End If If temp = "" Then temp = Cstr(row.Index) End If
If Len(rowArg) > 0 Then rowArg = temp + ";" + rowArg Else rowArg = temp End If row = parentRow LOOP On Error Goto 0 GetRowArg = rowArgEnd Function
As an aside, as this is not related to the original question, please in the future post a new question.
Mike,
Great Thanks for your info...
How can i select for single band grid cell ??
Thanks,
Sridhar
The solution I gave will work for a single band. If you really want to tailor it down so that it ONLY works for a single band, all you need is the column key and the row index.
Hi Mike,
Thank you for your Great Support...
Hi Sridhar,
I can only guess that you may have copied the code I gave you incorrectly, as ParentRow as an object is not used after it is set except in an If block that checks to see if the ParentRow is empty, which should by definition make the error that you have described impossible if it was copied correctly.
I would suggest that you review how you implemented what I sent you previously, or just use my other suggestion, in the case of you using this in a single band only scenario, just use the row.Index for the row parameter of the SelectCell TestAdvantage method.
If you require additional assistance on this matter I would highly suggest you contact our developer support as they would be able to assist you better.
Below is the code. We are using TD 2007 Vol 3. Please help us in this regard.
oAct.ActiveRow["Click"]
Thank you inadvance...