TouchButton Action (Specific to iOS Alert View)

Applies to TestComplete 15.63, last modified on April 10, 2024
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.


The TouchButton action simulates touching AlertView button in an application.



TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
Button [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.


The method has the following parameter:


You can enter the button'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.

Result Value



The following example performs the touch on the OK button.

JavaScript, JScript

function Test()
  // Select the mobile device
  // Obtain the AlertView object
  var p = Mobile.Device().Process("SampleApp");
  var alertview = p.Window(2).AlertView("Alert title");


def Test():
  # Select the mobile device
  # Obtain the AlertView object 
  p = Mobile.Device().Process("SampleApp")
  alertview = p.Window(2).AlertView("Alert title")


Sub Test()
  Dim p, AView
  ' Select the mobile device
  ' Obtain the tableview object
  Set p = Mobile.Device.Process("SampleApp")
  Set AView = p.Window(2).AlertView("Alert title")
  Call AView.TouchButton("OK")
End Sub


procedure Test();
  p, alertview;
  // Select the mobile device
  // Obtain the AlertView object
  p := Mobile.Device.Process('SampleApp');
  alertview := p.Window(2).AlertView('Alert title');

C++Script, C#Script

function Test()
  // Select the mobile device
  // Obtain the AlertView object
  var p = Mobile["Device"].Process("SampleApp");
  var alertview = p["Window"](2)["AlertView"]("Alert title");

See Also

Touching Alert View Buttons
iOS AlertView Support

Highlight search results