Forum Discussion

Ajaypokharkar's avatar
Regular Visitor
5 years ago

GetRowWithCellText method for Grid


I am working on an application which has a documents Grid. The grid has more than 10000 rows, we have option to filter but even on filtering the row no of specific row does not change eg, my intended row to work on is at 105 position, if i apply filter and get only 2 visible rows, the row no of intended row still shows as 105. 

Is there any method in testcomplete which can return us row no of gird using searching specific unique text like we have a method in UFT as GetRowWithCellText("String_Text") ?

3 Replies

  • TanyaYatskovska's avatar
    SmartBear Alumni (Retired)

    Thanks for the great suggestions, Wamboo, anupamchampati.

    Ajaypokharkar, do they help you resolve the issue? Which reply can we mark as a solution?



  • anupamchampati's avatar
    Frequent Contributor

    I have written one function to get the row index and click on the specific grid depending on the value (Text)


    You have specify the Grid object, and column name in which you have the values and the values 


    function ClickGrid(Grid,Column,Value)
    var RowIndex;
    function FindRow(Grid, Column, Value, ViewId)
    if (typeof(ViewId) == "undefined")
    ViewId = 0;
    for (var i=0; i<Grid.wRowCount(ViewId); i++)
    if (Grid.wValue(i, Column, ViewId) == Value)
    return i;
    return -1;
    RowIndex = FindRow(Grid,Column,Value);

  • Wamboo's avatar
    Community Hero

    Hi Ajaypokharkar

    There is few solutions for you, check this points:

    1) Use TestComplete 'text-recognition' option. With this option on You can search for any element currently visible on screen. For example if you have 5 rows in your grid and with third row you have a text 'document1' then you can search for this text as TextObject and read its properties.

    2) Second solution its to deploy application in 'Debug mode', after that you can natively read grid properties like:

    readSecondRowInSecondColumn() (method name its fake ;))

    3) Third the most weird one is to read all property values by its 'Top' coordinates. For example the third row is always in the same line so it's Top coordinates will be for example 50 px. With this knowledge you can read all data in all columns for single row.

    Hope this helps you.