Selecting Picker View Items

Applies to TestComplete 15.69, last modified on November 13, 2024

When working with a picker view control, you can use specific properties and methods of the iOS PickerView object that corresponds to this control. This topic explains how to select single and multiple picker view items.

Selecting a Picker View Item

To select a single picker view item, you can use various actions provided by the iOS PickerView object:

All these actions have the Item parameter that specifies the caption or zero-based index of the desired item. Note that it is possible to use wildcards (* and ?) or regular expressions to specify an item’s caption. You may also specify the index of the wheel. If the wheel is not specified, the first wheel is used.

The following example demonstrates how you can perform the touch on the picker view control:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the PickerView object
  var p = Mobile.Device().Process("SampleApp");
  var pickerview = p.Window(3).ActionSheet().PickerView();

  // Touch PickerView item
  pickerview.TouchItem(1, 0)
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the PickerView object 
  p = Mobile.Device().Process("SampleApp")
  pickerview = p.Window(3).ActionSheet().PickerView()

  # Touch PickerView item
  pickerview.TouchItem(1, 0)

VBScript

Sub Test()
  Dim p, pickerview
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the PickerView object
  Set p = Mobile.Device.Process("SampleApp")
  Set pickerview = p.Window(2).ActionSheet.PickerView

  ' Touch PickerView item
  Call pickerview.TouchItem(1, 0)
End Sub

DelphiScript

procedure Test();
var
  p, pickerview;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the PickerView object
  p := Mobile.Device.Process('SampleApp');
  pickerview := p.Window(3).ActionSheet.PickerView;

  // Touch PickerView item
  pickerview.TouchItem(1,0);
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the PickerView object
  var p = Mobile["Device"].Process("SampleApp");
  var pickerview = p["Window"](3)["ActionSheet"]()["PickerView"]();

  // Touch PickerView item
  pickerview.TouchItem(1, 0);
}

Selecting Picker View Items From Keyword Tests

To select picker view items from keyword tests, call the methods described above by using the On-Screen Action or Call Object Method operation. See Calling Object Methods.

See Also

Working With iOS Picker View Controls
Getting the Selected Picker View Item
iOS PickerView Support
TouchItem Method (Specific to iOS Picker View Controls)
LongTouchItem Action (Specific to iOS Picker View Controls)

Highlight search results