Working With Stepper Buttons

Applies to TestComplete 15.47, last modified on January 20, 2023

General Notes

TestComplete recognizes stepper controls in iOS Open Applications. Stepper controls are associated with the iOS Stepper test objects that contain specific methods for simulating user actions and for obtaining a control’s data.

A stepper control typically displays two buttons: one of them contains the minus symbol, the other - the plus symbol. TestComplete creates wrapper iOS Button objects for these buttons. In the object hierarchy, the iOS Button objects corresponding to the buttons of a stepper control are the child objects of the corresponding iOS Stepper object.

Specifics of Working With Stepper Buttons

When working with stepper controls, it is easier to use specific methods and properties of the iOS Stepper test object, since it hides the details of the underlying control from tests. For example, to change the value of a stepper control, you can assign a new value to the wPosition property rather than simulate touch actions over the plus or minus button. However, you can also work with the corresponding iOS Button objects. For example, to determine whether a stepper button is active, you can check the Enabled property of the desired button object.

Getting the Value of the Enabled Property of a Stepper Button

To check if a stepper button is active, use the Enabled property. If the button is enabled, this property returns True; otherwise, False. The following example demonstrates how to check the state of a button:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the stepper object
  var p = Mobile.Device().Process("SampleApp");
  var ButtonDown = p.Window(0).Stepper(1).Button("", 0);
   
  if (ButtonDown.Enabled)
    ButtonDown.Touch();
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the stepper object
  p = Mobile.Device().Process("SampleApp")
  ButtonDown = p.Window(0).Stepper(1).Button("", 0)
   
  if (ButtonDown.Enabled):
    ButtonDown.Touch()

VBScript

Sub Test()
  Dim p, stepper, ButtonDown
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the stepper object
  Set p = Mobile.Device.Process("SampleApp")
  Set ButtonDown = p.Window(0).Stepper(1).Button(0)
   
  If ButtonDown.Enabled Then
    ButtonDown.Touch()
  End If
End Sub

DelphiScript

procedure Test();
var
  p, ButtonDown;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the stepper object
  p := Mobile.Device.Process('SampleApp');
  ButtonDown := p.Window(0).Stepper(1).Button('', 0);
   
  if ButtonDown.Enabled then
    ButtonDown.Touch();
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the stepper object
  var p = Mobile["Device"].Process("SampleApp");
  var ButtonDown = p["Window"](0)["Stepper"](1)["Button"]("", 0);
   
  if (ButtonDown["Enabled"])
    ButtonDown["Touch"]();
}

Note: If the maximum or minimum value of the stepper control is reached, the corresponding button becomes disabled. If you try to simulate a touch on it, an error will be posted to the test log.
Checking the State of a Stepper Button in Keyword Tests

To check whether a stepper button is enabled, you can use the If Object operation. You can also check the value of the described Enabled property by using various keyword test operations.

See Also

Working With iOS Stepper Controls
iOS Button Support

Highlight search results