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:
TouchItem
,LongTouchItem
, and similar actions: Simulate touch or long touch on a specific list view item.
All these actions have two parameters:
-
Group - specifies the caption or zero-based index of the desired group.
Note: Note that it is possible to use wildcards (* and ?) or regular expressions to specify a group caption. For more information, see Addressing Expandable List Groups and Items. -
Item - specifies the zero-based index of the desired item within the group.
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)