Expandable list controls display a two-level list of items. Each list group can have a number of child items. Child items are displayed when their parent group is expanded, and they are hidden when the parent group is collapsed.
Using Internal Methods
You can create and play back a test that expands and collapses a list of groups. To do this, use the Expand
and Collapse
actions of the Android ExpandableList
object that corresponds to the tested expandable list.
You can expand or collapse all the groups of the list by setting the Group parameter to -1.
The wIsExpanded
property lets you determine whether a specific list group is expanded or collapsed.
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.RootLayout("").ExpandableListView("list");
// Expand the first group
expList.Expand(0);
// Expand the "Group 3"
expList.Expand("Group 3");
// Check the group's state
if (expList.wIsExpanded("Group 3"))
{
Log.Message("The Group is expanded")
}
// Collapse all the groups
expList.Collapse(-1);
}
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.RootLayout("").ExpandableListView("list")
# Expand the first group
expList.Expand(0);
# Expand the "Group 3"
expList.Expand("Group 3")
# Check the group's state
if expList.wIsExpanded["Group 3"]:
Log.Message("The Group is expanded")
# Collapse all the groups
expList.Collapse(-1)
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
expList = app.RootLayout("").ExpandableListView("list")
' Expand the first group
expList.Expand(0)
' Expand the "Group 3"
expList.Expand("Group 3")
' Check the group's state
If ExpList.wIsExpanded("Group 3") Then
Log.Message("The Group is expanded")
End If
' Collapse all the groups
expList.Collapse(-1)
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.RootLayout('').ExpandableListView('list');
// Expand the first group
expList.Expand(0);
// Expand the 'Group 3'
expList.Expand('Group 3');
// Check the group's state
if expList.wIsExpanded('Group 3') then
begin
Log.Message('The Group is expanded')
end;
// Collapse all the groups
expList.Collapse(-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 an expandable list
var expList = app["RootLayout"]("")["ExpandableListView"]("list");
// Expand the first group
expList["Expand"](0);
// Expand the "Group 3"
expList["Expand"]("Group 3");
// Check the group's state
if (expList["wIsExpanded"]("Group 3"))
{
Log["Message"]("The Group is expanded")
}
// Collapse all the groups
expList["Collapse"](-1);
}
Simulating Actions From Keyword Tests
This topic explains how to expand or collaps groups of the expandable list control in scripts. You can use the described actions and properties 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
Collapse Action (Android Controls)
Expand Action (Android Controls)
wIsExpanded Property (Android Controls)