Obtaining Cell Values in Android Grid View Controls

Applies to TestComplete 15.70, last modified on December 17, 2024

This topic describes approaches that you can use to obtain values stored in Android grid view cells. Note that before getting the cell value, you need to know in which row and column the needed cell resides. For example, you can search for the row containing the needed cell within the grid.

Obtaining Cell Values

To get the value from a particular grid cell, you can use the wValue property of the Android GridView object. The property has the Row and Column parameters which specify the row and the column that contain the cell. The code snippet below demonstrates how you can get values of grid view cells via the wValue property.

JavaScript, JScript

function Test()
{
  // Select an Android device
  Mobile.SetCurrent("MyDevice");

  // Obtain an application
  var app = Mobile.Device().Process("com.example.myapp")

  // Obtain a grid view
  var gridViewObj = app.RootLayout("").Layout("layoutTop").GridView("gv_simple");
  
  // Obtain a value of a grid view cell
  Log.Message(gridViewObj.wValue(8, 1));
}

Python

def Test():
  # Select an Android device
  Mobile.SetCurrent("MyDevice")

  # Obtain an application
  app = Mobile.Device().Process("com.example.myapp")

  # Obtain a grid view 
  gridViewObj = app.RootLayout("").Layout("layoutTop").GridView("gv_simple")
  
  # Obtain a value of a grid view cell
  Log.Message(gridViewObj.wValue[8, 1])

VBScript

Sub Test
  ' Select an Android device
  Mobile.SetCurrent("MyDevice")

  ' Obtain an application
  Set app = Mobile.Device.Process("com.example.myapp")

  ' Obtain a grid view
  Set gridViewObj = app.RootLayout("").Layout("layoutTop").GridView("gv_simple")
  
  ' Obtain a value of a cell and post it to the Log
  Log.Message(gridViewObj.wValue(8, 1))

End Sub

DelphiScript

procedure Test();
var
  app, gridViewObj: OleVariant;
begin
  // Select an Android device
  Mobile.SetCurrent('MyDevice');

  // Obtain an application
  app := Mobile.Device.Process('com.example.myapp');

  // Obtain a grid view
  gridViewObj := app.RootLayout('').Layout('layoutTop').GridView('gv_simple');
  
  // Obtain a value of a cell and post it to the log
  Log.Message(gridViewObj.wValue(8,1));
end;

C++Script, C#Script

function Test()
{
  // Select an Android device
  Mobile["SetCurrent"]("MyDevice");

  // Obtain an application
  var app = Mobile["Device"]["Process"]("com.example.myapp")

  // Obtain a grid view
  var gridViewObj = app["RootLayout"]("")["Layout"]("layoutTop")["GridView"]("gv_simple");
  
  // Obtain a value of a grid view cell
  Log["Message"](gridViewObj["wValue"](8, 1));
}

Simulating Actions From Keyword Tests

This topic explains how to obtain a cell value of the grid view control in scripts. You can use the described actions in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Grid View Controls
Android GridView Support
Searching for Rows in Android Grid View Controls

Highlight search results