Selecting an ActionSheet Control's Item

Applies to TestComplete 14.30, last modified on November 21, 2019

One of the most frequent actions you perform on an action sheet control in an iOS application is selecting its items. This topic explains how you can select an action sheet control’s items from tests.

Simulating Touch Actions

To select a desired action sheet’s item in your iOS application, simulate a touch on that item. To simulate touching an item, you can use the TouchItem method of the iOS ActionSheet test object that TestComplete associates with action sheets in iOS applications. This method simulates a single short touch on the specified item.

The following example demonstrates how to perform a touch by using the method:

JavaScript, JScript

function Test()
{

  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the ActionSheet object
  var p = Mobile.Device().Process("SampleApp");
  var actionSheet = p.Window(0).ActionSheet();

  // Touch the "Item" item
  actionSheet.TouchItem("Item");

}

Python

def Test():

  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the ActionSheet object
  p = Mobile.Device().Process("SampleApp")
  actionSheet = p.Window(0).ActionSheet()

  # Touch the "Item" item
  actionSheet.TouchItem("Item")

VBScript

Sub Test

  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the ActionSheet object
  Set p = Mobile.Device.Process("SampleApp")
  Set actionSheet = p.Window(0).ActionSheet

  ' Touch the "Item" item
  actionSheet.TouchItem("Item")

End Sub

DelphiScript

procedure Test();
var p, actionSheet;
begin

  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the ActionSheet object
  p := Mobile.Device.Process('SampleApp');
  actionSheet := p.Window(0).ActionSheet();

  // Touch the "Item" item
  actionSheet.TouchItem('Item');

end;

C++Script, C#Script

function Test()
{

  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the ActionSheet object
  var p = Mobile["Device"]["Process"]("SampleApp");
  var actionSheet = p["Window"](0)["ActionSheet"]();

  // Touch the "Item" item
  actionSheet["TouchItem"]("Item");

}
Note: You can only touch an item if it is enabled. To learn how to determine an item’s state, see Checking an ActionSheet Item's State.

Selecting Items From Keyword Tests

To select an ActionSheet’s item 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 ActionSheet Controls
iOS ActionSheet Support
Checking an ActionSheet Item's State
TouchItem Method (Mobile Controls)

Highlight search results