MultiSelect Method (Specific to iOS TableView Controls)

Applies to TestComplete 15.47, last modified on January 20, 2023
This method is available in legacy mobile tests that work with devices connected to the local computer. To learn how to simulate user actions in newer cloud-compatible mobile tests, see the Simulating user actions in tests section.

Description

The MultiSelect method selects multiple items in the table view.

Declaration

TestObj.MultiSelect(Section, Items)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Section [in]    Required    Variant    
Items [in]    Required    Variant    
Result None

Applies To

The method is applied to the following object:

View Mode

This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.

Parameters

The method has the following parameters:

Section

Specifies the section of the desired item. You can enter the section’s index (from 0) or its caption. The caption can contain asterisk (*) or question mark (?) wildcards or regular expressions. The asterisk (*) corresponds to a string of any length (including an empty string), the question mark corresponds to any single character (including none). To specify more complicated parts of a caption, use regular expressions.

The caption can be case-sensitive or case-insensitive depending on the value of the Use case-sensitive parameters project setting.

Items

This parameter can be either of the following:

  • An array containing captions or indexes of items to select. You can use “native” JavaScript, JScript, Python, VBScript and DelphiScript arrays as well as arrays created using the CreateVariantArray function.

  • String holding the captions of items to select, separated by the wListSeparator characters.

Item captions can contain wildcard characters - * and ?. The asterisk (*) corresponds to a string of any length, the question mark (?) - to any single character. Captions can be case-sensitive or case-insensitive depending on the value of the Use case-sensitive parameters project setting.

Result Value

None.

Remarks

If the control does not support multiselection, no action is performed and an error is posted to the test log.

If there are items already selected in the specified section of the control, the method first clears the selection in these sections, and then selects the specified items. The item selection in other sections does not change.

Example

This example script selects first six items in the first section of an application’s table view.

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the TableView object
  var p = Mobile.Device().Process("SampleApp");
  var tableview = p.Window().TableView();
  
  // Create an array of items you want to select
  var items = new Array(tableview.wItemCount(0))
  for (i=0; i<tableview.wItemCount(0);i++)
    items[i] = i
    
  // Select the items
  tableview.Multiselect(0, items);
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the TableView object 
  p = Mobile.Device().Process("SampleApp")
  tableview = p.Window().TableView()
  
  # Create an array of items you want to select
  items = []
  for i in range (0, tableview.wItemCount[0]):
    items.append(i)
    
  # Select the items 
  tableview.Multiselect(0, items)

VBScript

Sub Test()
  Dim p, tableview
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the tableview object
  Set p = Mobile.Device.Process("SampleApp")
  Set tableview = p.Window.TableView
  
  ' Create an array of items you want to select
  Dim items(5)
  For i = 0 to 5
    items(i) = i
  Next
  ' Select the items
  Call tableview.MultiSelect(0,items)
End Sub

DelphiScript

procedure Test();
var
  p, tableview, i;
  items : array[0..5] of variant;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the tableview object
  p := Mobile.Device.Process('SampleApp');
  tableview := p.Window(0).TableView(0);
  
  // Create an array of items you want to select
  for i := 0 to 5 do
    items[i] := i;
  
  // Select the items
  tableview.MultiSelect(0, items);
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the TableView object
  var p = Mobile["Device"].Process("SampleApp");
  var tableview = p["Window"]()["TableView"]();
  
  var items = new Array(tableview.wItemCount(0))
  for (i=0; i<5;i++)
    items[i] = i
  tableview["Multiselect"](0, items);
}

See Also

Selecting Table View Items
Testing iOS Applications (Legacy)

Highlight search results