Determining ScrollView Position

Applies to TestComplete 14.60, last modified on April 22, 2021
Determining the ScrollView Position

To determine the position of a ScrollView control, use the wPositionX and wPositionY properties of the iOS ScrollView object that TestComplete associates with that control. The following example checks the position of ScrollView and posts it to the log:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the ScrollView object
  var p = Mobile.Device().Process("SampleApp");
  var scrollview = p.Window().ScrollView();

  // Post ScrollView position to the log
  Log.Message(scrollview.wPositionX);
  Log.Message(scrollview.wPositionY);
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the ScrollView object 
  p = Mobile.Device().Process("SampleApp")
  scrollview = p.Window().ScrollView()

  # Post ScrollView position to the log
  Log.Message(scrollview.wPositionX)
  Log.Message(scrollview.wPositionY)

VBScript

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

  ' Post ScrollView position to the log
  Log.Message(scrollview.wPositionX)
  Log.Message(scrollview.wPositionY)
End Sub

DelphiScript

procedure Test();
var
  p, scrollview;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the ScrollView object
  p := Mobile.Device.Process('SampleApp');
  scrollview := p.Window.ScrollView;

  // Post ScrollView position to the log
  Log.Message(scrollview.wPositionX);
  Log.Message(scrollview.wPositionY);
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the ScrollView object
  var p = Mobile["Device"].Process("SampleApp");
  var scrollview = p["Window"]()["ScrollView"]();

  // Post ScrollView position to the log
  Log["Message"](scrollview["wPositionX"]);
  Log["Message"](scrollview["wPositionY"]);
}

Getting Position From Keyword Tests

To get the current scroll view position 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 Scroll View Controls
Changing ScrollView Position
wPositionX Property (iOS Controls)
wPositionY Property (iOS Controls)

Highlight search results