Forum Discussion

Know's avatar
Know
Occasional Contributor
24 days ago

TestComplete detects the table control itself, but none of the internal row/cell objects are exposed

I have a table-like control similar to the one in the screenshot.

Using "Add Object" in TestComplete, I can capture the main table object. (object: Aliases.Icad.dlgAECStylesManager.Item.SysListView32)
However, when I explore it in the Object Browser, the table exposes only one child object — the header.
There are no row objects, no cell objects, and no data nodes visible under the table.

Because of this, TestComplete cannot interact with the table using the normal object model (such as row/cell access, FindChild, ClickCell, etc.).

My goal is to automate editing based on the row index.
For example:
Update the “Name” column for the row where Index = 101 (change it to "Testing1").

Has anyone encountered this type of control or found a reliable solution for automating tables that do not expose row/cell objects?

Any suggestions would be greatly appreciated.

Thanks!

10 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Hi Know​ . Is this the same application you were having issues with when trying to select items from the combo box? If yes, then it's a WPF application (It's important to mention the technology your application uses). What does the Object Browser show for your control?

    I've created a WPF application which has a similar control to yours. Looking at the Object Browser, TestComplete exposes the WPFObject("DataGrid", "", 1) object and all the child objects beneath it. If I look at the Extended properties of WPFObject("DataGrid", "", 1) object, I can retrieve the necessary value from a particular row & column using wValue property, as shown below

    Object Browser - Using wValue to retrieve value "Load" from row 3 and column "Function"

    If your grid control is not exposing similar objects, try to enable MSAA, in Project -> Properties -> Open Application -> MSAA.

     

    • Know's avatar
      Know
      Occasional Contributor

      rraghvani​ it has same application, but on the different dialog

      Because as I mentioed, datagrid is not expose any cell, So I cannot use wValue to retrieve any value

      • torus's avatar
        torus
        Frequent Contributor

        So something like this wouldn't work? (Note: all the code examples i list here are in Javascript). 

        var list = Aliases.Icad.dlgAECStylesManager.Item.SysListView32;
        
        var rowCount = list.wItemCount;
        for (var r = 0; r < rowCount; r++) {
            for (var c = 0; c < 6; c++) {
                Log.Message("Row " + r + ", Col " + c + ": " + list.wSubItem(r, c));
            }
        }

         

  • torus's avatar
    torus
    Frequent Contributor

    You might already be aware of the below but it took me a while to figure out ...

    Additionally, for some tables, it is not always obvious how to retrieve a cell and retrieve the cell data (because of the objects the developer used to create the table). 

    Sometimes you can access table data as you would expect (like you would in Excel) using the table.Cell(row,column) function like shown below:

    function getRow()
    {
      var table = Aliases.MyApp.ATable;
    
      var numOfRows = table.RowCount;
      var foundRow = -1;
      for(let row = 0; row < numOfRows; row++)
      {
        var cellText = table.Cell(row, 0).Text;
        if(cellText === ItemName)
        {
          foundRow = row;
          break;
        }
      }
      return foundRow;
    }

    and then sometimes you access table data through an iterator like shown below

    function Update_Table_()
    {
      // Comment: 
      //   The table contents in the file has a '\n' at the end of each line and instead of the columns being separated
      //    by a comma, the columns are separated by '|' verticle line.  
      var table = Aliases.myApp.ATable;
      
      var items = table.Items;
      var totalRows = items.Count;
      var contentForFile = "";
      
      for(var row = 0 ; row < totalRows; row++)
      {
        var item = items.Item(row);
        var description = item.Description_2.OleValue;
        var stringVal = item.StringValue.OleValue;
        var name = item.Suffix.OleValue;
        var units = item.UnitsName.OleValue;
        
        contentForFile = contentForFile + 
        `${name}|${stringVal}|${units}|${description}\n`;
      }
      
      aqFile.WriteToTextFile("C:\\Temp3\\DescriptionSortAscending.txt", contentForFile, aqFile.ctUTF8, true);
    }

     

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Hi Know,

    Do any of the exposed controls contain methods that can be used to navigate the grid?  Some grid controls can only be navigated in this way.  I would also recommend using record and replay to create a script that will expose what TestComplete sees as you manually navigate the control.  Sometimes this only comes up with x,y clicks but it's worth a try.  😉


     ... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎

  • torus's avatar
    torus
    Frequent Contributor

    If you can't find any way to actually access the table object, you can always use the OCR table recognize feature:

     

    function OCR_Table(tableObject, hasHeader = true)
    {
      // -- OCRTable Object ---
      // Specify the preferable search area
      var searchPref = spNone;
      // Recognize the table content
      var table = OCR.Recognize(tableObject).DetectTable(searchPref, hasHeader);
      return table;
    }
    

    You can find more about this at the following link: TestComplete - Detect Table

  • Know's avatar
    Know
    Occasional Contributor

    Hi all,

    I tried all the ways you mentioned but it didn't work

    My table belongs to datagrid. And it don't have any object cells. > that's why I cannot retrieve the value as normally

     

    • rraghvani's avatar
      rraghvani
      Icon for Champion Level 3 rankChampion Level 3

      Now that you have provided a screenshot of the Object Browser, I can see that it's not a WPF application, but most likely a Windows 32 application!

      Here's a Windows 32 application that I've created, having SysListView32 control, again similar control to yours -

      If you enable MSAA, TestComplete will see more objects

      MSAA enabled in Project Settings

      If you enable UI Automation, TestComplete may see more/less objects

      UI Automation enabled in Project Settings

      You can use and modify the appropriate Property parameters to retrieve the data you require (either ask ChatGPT or research the Microsoft website on how to do this)

      Or you could try use the Methods provided

      More information can be found here Working With List View Controls in Desktop Windows Applications

      Note, although UI controls look similar, the technology they use will most likely be different. So there's no real answer to this - you will have to study the Properties and Method exposed by TestComplete and see what you can use.

    • Know's avatar
      Know
      Occasional Contributor

      Hi all,

      Pls get my update

      Now I can click/update the cell value use datagridObject.ClickItem(indexX, indexY)

      But now I'm facing the new issue: unable to retries the data from datagrid

      The purpose: verify the value after entering

      Does anyone have solutions to retries data? Object of datagrid that I 've provided in the previous comment (screenshot)

      thanks,