Changing the Value of a Stepper Control

Applies to TestComplete 14.30, last modified on November 21, 2019
Specifying the wPosition Property

To specify a value for a stepper control, use the wPosition property. This property allows you to specify a value within the range of the maximum and minimum values. When you specify a value, no message is posted to the test log.

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the stepper object
  var p = Mobile.Device().Process("SampleApp");
  var stepper = p.Window(0).Stepper(1);
  
  // Specify 50 as the value
  stepper.wPosition = 50;
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the stepper object
  p = Mobile.Device().Process("SampleApp")
  stepper = p.Window(0).Stepper(1)
  
  # Specify 50 as the value
  stepper.wPosition = 50

VBScript

Sub Test()
  Dim p, stepper
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the stepper object
  Set p = Mobile.Device.Process("SampleApp")
  Set stepper = p.Window(0).Stepper(1)
  
  ' Specify 50 as the value
  stepper.wPosition = 50
End Sub

DelphiScript

procedure Test();
var
  p, stepper;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the stepper object
  p := Mobile.Device.Process('SampleApp');
  stepper := p.Window(0).Stepper(1);
  
  // Specify 50 as the value
  stepper.wPosition := 50;
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 stepper = p["Window"](0)["Stepper"](1);
  
  // Specify 50 as the value
  stepper["wPosition"] = 50;
}

If you try to specify a value that is greater than wMax or less than wMin, the wMax or wMin value will be specified instead.
Calling the Up and Down Methods

To increment or decrement the value of a stepper control, use the Up and Down methods. These methods simulate a touch on the corresponding button. The following example changes the value of a stepper control until the value 50 is set:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the stepper object
  var p = Mobile.Device().Process("SampleApp");
  var stepper = p.Window(0).Stepper(1);
  
  // Increment or decrement the control value until it equals 50
  if (stepper.wPosition<50)
    while (stepper.wPosition<50)
      stepper.Up();
  else
    while (stepper.wPosition>50)
      stepper.Down()
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the stepper object
  p = Mobile.Device().Process("SampleApp")
  stepper = p.Window(0).Stepper(1)
  
  # Increment or decrement the control value until it equals 50
  if (stepper.wPosition<50):
    while (stepper.wPosition<50):
      stepper.Up()
  else:
    while (stepper.wPosition>50):
      stepper.Down()

VBScript

Sub Test()
  Dim p, stepper
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the slider object
  Set p = Mobile.Device.Process("SampleApp")
  Set stepper = p.Window(0).Stepper(1)
  
  ' Increment or decrement the control value until it equals 50
  If stepper.wPosition < 50 Then
    Do while stepper.wPosition < 50
     Call stepper.Up
    Loop
  Else
    Do while stepper.wPosition > 50
      stepper.Down()
    Loop
  End If
End Sub

DelphiScript

procedure Test();
var
  p, stepper;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the slider object
  p := Mobile.Device.Process('SampleApp');
  stepper := p.Window(0).Stepper(1);
  
  // Increment or decrement the control value until it equals 50
  if stepper.wPosition < 50 then
    while (stepper.wPosition<50) do
      stepper.Up()
  else
    while (stepper.wPosition>50) do
      stepper.Down();
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 stepper = p["Window"](0)["Stepper"](1);
  
  // Increment or decrement the control value until it equals 50
  if (stepper.wPosition<50)
    while (stepper.wPosition<50)
      stepper["Up"]();
  else
    while (stepper.wPosition>50)
      stepper["Down"]()
}

If the button is disabled, no action is performed and an error is posted to the test log. The button may be disabled because the maximum or minimum value has been reached.
Changing the Value of a Stepper Control in Keyword Tests

You can change the value of a stepper control by specifying a value for the wPosition property or by calling the Up or Down method in keyword tests. To do this, use the On-Screen Action or Call Object Method operation.

See Also

Working With iOS Stepper Controls
Determining the Current Value of a Stepper Control

Highlight search results