Forum Discussion

sanjini's avatar
sanjini
New Contributor
6 years ago

Testcomplete-Desktop Application-How to get the ID of newly created record?

I am new to TestComplete and have an issue in which a new record is being added to the system using a winform application but I am not sure how to get the ID for the new record so that it can be used in other test steps to update/delete the same record. 

 

NOTE: I am using keyword test to automate my application

5 Replies

  • anupamchampati's avatar
    anupamchampati
    Frequent Contributor

    If you are aware of the Column value name, use this function to get the Row Index

     

    ClickGrid(GRID-Parentobject of TCXGRIDSITE,  Column Name, Value-New value which are creating from Testcomplete) Return this function, you will get the row index for the same.

     

    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);
    if (RowIndex != -1)
    {
    Grid.ClickCell(RowIndex, Column);
    Log.Message("Row index: " + RowIndex + " Column Name: " + Value);
    }
    else
    Log.Error("Row was not found");
    }

    • anupamchampati's avatar
      anupamchampati
      Frequent Contributor

      updated the function with return rowindex.

       

       

      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);
      if (RowIndex != -1)
      {
      Grid.ClickCell(RowIndex, Column);
      Log.Message("Row index: " + RowIndex + " Column Name: " + Value);

      return RowIndex
      }
      else
      Log.Error("Row was not found");
      }