Changing Slider Position

Applies to TestComplete 15.47, last modified on January 20, 2023
Assigning the wPosition Property

To specify a slider position, use the wPosition property. This property allows you to specify a value between the minimum and maximum values of the seek bar. When you specify a position, no message is posted to the test log.

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  
  // Obtain the slider object
  var p = Mobile.Device().Process("SampleApp");
  var slider = p.Window(0).Slider(1);
  
  // Assign a new value to the wPosition property
  slider.wPosition = 0.5;
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  
  # Obtain the slider object
  p = Mobile.Device().Process("SampleApp")
  slider = p.Window(0).Slider(1)
  
  # Assign a new value to the wPosition property
  slider.wPosition = 0.5

VBScript

Sub Test()
  Dim p, slider
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the slider object
  Set p = Mobile.Device.Process("SampleApp")
  Set slider = p.Window(0).Slider(1)

  ' Assign a new value to the wPosition property
  slider.wPosition = 0.5
End Sub

DelphiScript

procedure Test();
var
  p, slider;
begin

  // Select the mobile device
  Mobile.SetCurrent('iPhone');

  // Obtain the slider object
  p := Mobile.Device.Process('SampleApp');
  slider := p.Window(0).Slider(1);
  
  // Assign a new value to the wPosition property
  slider.wPosition := 0.5;
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  
  // Obtain the slider object
  var p = Mobile["Device"].Process("SampleApp");
  var slider = p["Window"](0)["Slider"](1);
  
  // Assign a new value to the wPosition property
  slider["wPosition"] = 0.5;
}

If you try to assign a value that is greater than wMax or less that wMin, the wMax or wMin value will be assigned instead.
Changing Slider Position in Keyword Tests

To change the slider position from keyword tests, use the On-Screen Action or Call Object Method operation to access the properties described above. See Getting and Setting Object Property Values.

See Also

Working With iOS Slider Controls
Determining Slider Position

Highlight search results