Selecting Expandable List Groups and Items

Applies to TestComplete 15.47, last modified on January 20, 2023
Using Internal Methods

When working with an expandable list control, you select items in the list. To select an expandable list item, you can use several actions provided by Android ExpandableList object:

All these actions have two parameters:

The following example demonstrates how you can use the mentioned actions in scripts:

JavaScript, JScript

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

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

  // Obtain an Expandable list
  var expList = app.Layout("layoutListView").ExpandableListView("elv1");
  
  // Touch some items within Group 1
  expList.TouchItem("Group 1", 0);
  expList.LongTouchItem("Group 1", 3);
}

Python

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

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

  # Obtain an Expandable list
  expList = app.Layout("layoutListView").ExpandableListView("elv1")
  
  # Touch some items within Group 1
  expList.TouchItem("Group 1", 0)
  expList.LongTouchItem("Group 1", 3)

VBScript

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

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

  ' Obtain an Expandable list
  Set expList = app.Layout("layoutListView").ExpandableListView("elv1")
  
  ' Touch some items within Group 1
  Call expList.TouchItem("Group 1", 0)
  Call expList.LongTouchItem("Group 1", 3)
End Sub

DelphiScript

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

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

  // Obtain an Expandable list
  expList := app.Layout('layoutListView').ExpandableListView('elv1');
  
  // Touch some items
  expList.TouchItem('Group 1', 0);
  expList.LongTouchItem('Group 1', 3);
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 an Expandable list
  var expList = app["Layout"]("layoutListView")["ExpandableListView"]("elv1");
  
  // Touch some items
  expList["TouchItem"]("Group 1", 0);
  expList["LongTouchItem"]("Group 1", 3);
}

Simulating Actions From Keyword Tests

This topic explains how to select items of the expandable list 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 Expandable List Controls
Android ExpandableList Support
TouchItem Method (Specific to Android ExpandableList Controls)
LongTouchItem Action (Specific to Android ExpandableList Controls)

Highlight search results