ValueByName Property

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

The ValueByName property lets you obtain the value stored in the cell, which is specified by its column’s name.

Declaration

LogTableRowObj.ValueByName(ColumnName)

Read-Only Property Variant
LogTableRowObj An expression, variable or parameter that specifies a reference to a LogTableRow object
ColumnName [in]    Required    String    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

ColumnName

The name of the column holding the desired cell. To determine the name of the column needed, explore the test log or use the Name property of the corresponding LogColumn object.

Property Value

The value of the specified cell. It can be an integer or a floating-point number, a string, a boolean, a date-time value, a hyperlink or an image.

Note: To determine the type of values in the given table column, you can use the LogColumn.DataType property.

Remarks

To obtain the desired value, you can also use the Value or ValueByIndex property.

Example

The following example demonstrates how to obtain the value stored in the specified cell.

JavaScript, JScript

function TableDataRowSample()
{
  var Logs, LogItem, LogData, DType, Row, Column, Value;
  // Obtains a log item
  Logs = Project.Logs;
  LogItem = Logs.LogItem(0);
  // Obtains the log item’s dataset
  LogData = LogItem.Data(0);

  DType = LogData.Scheme.DataType;
  // Checks whether the dataset corresponds to the table
  if (DType == 0)
  {
    // Obtains a table row by its index
    Row = LogData.Rows(0);
    // Obtains the value stored in the cell by the column name
    Value = Row.ValueByName("Message");
    // Posts the value to the test log
    Log.Message(aqConvert.VarToStr(Value));
  }

}

Python

def TableDataRowSample():
  # Obtains a log item
  Logs = Project.Logs
  LogItem = Logs.LogItem[0]
  # Obtains the log item's dataset
  LogData = LogItem.Data[0]
  DType = LogData.Scheme.DataType
  # Checks whether the dataset corresponds to the table
  if DType == 0:
    # Obtains a table row by its index
    Row = LogData.Rows[0]
    # Obtains the value stored in the cell by the column name
    Value = Row.ValueByName["Message"]
    # Posts the value to the test log
    Log.Message(aqConvert.VarToStr(Value))

VBScript

Sub TableDataRowSample

  ' Obtains a log item
  Set Logs = Project.Logs
  Set LogItem = Logs.LogItem(0)
  ' Obtains the log item’s dataset
  Set LogData = LogItem.Data(0)

  DType = LogData.Scheme.DataType
  ' Checks whether the dataset corresponds to the table
  If DType = 0 Then
    ' Obtains a table row by its index
    Set Row = LogData.Rows(0)
    ' Obtains the value stored in the cell by the column name
    Value = Row.ValueByName("Message")
    ' Posts the value to the test log
    Log.Message(aqConvert.VarToStr(Value))
  End If

End Sub

DelphiScript

procedure TableDataRowSample();
var Logs, LogItem, LogData, DType, Row, Column, Value;
begin
  // Obtains a log item
  Logs := Project.Logs;
  LogItem := Logs.LogItem[0];
  // Obtains the log item’s dataset
  LogData := LogItem.Data[0];

  DType := LogData.Scheme.DataType;
  // Checks whether the dataset corresponds to the table
  if DType = 0 then
  begin
    // Obtains a table row by its index
    Row := LogData.Rows[0];
    // Obtains the value stored in the cell by the column name
    Value := Row.ValueByName['Message'];
    // Posts the value to the test log
    Log.Message(aqConvert.VarToStr(Value));
  end;

end;

C++Script, C#Script

function TableDataRowSample()
{
  var Logs, LogItem, LogData, DType, Row, Column, Value;
  // Obtains a log item
  Logs = Project["Logs"];
  LogItem = Logs.LogItem(0);
  // Obtains the log item’s dataset
  LogData = LogItem["Data"](0);

  DType = LogData["Scheme"]["DataType"];
  // Checks whether the dataset corresponds to the table
  if (DType == 0)
  {
    // Obtains a table row by its index
    Row = LogData["Rows"](0);
    // Obtains the value stored in the cell by the column name
    Value = Row["ValueByName"]("Message");
    // Posts the value to the test log
    Log["Message"](aqConvert["VarToStr"](Value));
  }

}

See Also

Access Test Log Contents from Tests
Value Property
ValueByIndex Property
LogColumn Object

Highlight search results