Forum Discussion

Karthik_gowda's avatar
Karthik_gowda
Occasional Contributor
4 months ago

Assistance with Fetching Values from Grid Identified by 'AcuGridClass' property

Has anyone encountered a grid identified by the AcuGridClass property? If so, I need guidance on how to fetch a value, specifically from the status column, which could be 7th column for order status. Could you please advise on the best approach to retrieve this value? also code snippet in JS if any would help

  • JDR2500's avatar
    JDR2500
    Frequent Contributor

    I have worked with a variety of grids in desktop applications but not anything by that name.  Hopefully I'm not telling you what you already know. 
    There are two scenarios I often encounter:

    a) TC recognizes the grid as a grid and provides access to the contents (e.g. cells, rows, columns, etc.) via various properties and methods that can be viewed using the object spy as seen below and utilized in scripts.

    The wValue property, as seen above, will let you get any cell value by specifying the row (by index only) and column (either by index or header text).

    The indexes are zero-based so the seventh column would be 6.  You could get the value of the first cell in that column something like this:

    value = mygrid.wValue 0, "Status"
    or using indexes:
    value = mygrid.wValue 0, 6

    b) TC doesn't recognize the grid and therefore the grid related properties and methods don't work.  In this case I have used the ugly solution of clicking in the top left cell of the grid (e.g. mygrid.Click 5,5) and then sending arrow keystrokes (e.g. mygrid.Keys("[Right][Right][Down]") to navigate to the cell with the value I want to verify.  Once the cell is selected, I copy the value to the clipboard (e.g. mygrid.Keys("^c") and verify it with a clipboard checkpoint.  Sorry I only do VBScript.

    If (aqString.StrMatches("27", Aliases.Sys.Clipboard) = True) Then
    	Call Log.Checkpoint("The value is correct.")
      Else
    	Call Log.Warning("The expected value was not found")
    End If

    The second method I've used when TC doesn't recognize the grid is the IQ Add-in.  It can recognize tables and contained values.  Here is a link to the relevant help topic:

    OCRTable Object | TestComplete Documentation (smartbear.com)

    Again, I apologize in advance if all of this is already known to you.