Determining the Scroll View Position

Applies to TestComplete 15.46, last modified on January 09, 2023
Getting the wPosition Property

To determine the position of the scroll view slider, use the wPosition property. This property returns the current position of the scroll view slider. The following example demonstrates how to obtain the position of the scroll view slider:

JavaScript, JScript

function Test()
{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");
   
  // Obtain the ScrollView object
  var p = Mobile.Device().Process("com.example.myapp");
  var ScrollView = p.RootLayout("").Layout("layoutTop").Layout("layout1").ScrollView("VerticalScrollView1");
  
  // Obtain the wPosition value
  var Position = ScrollView.wPosition;
  
  // Post the position to the log
  Log.Message(Position);
}

Python

def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")
   
  # Obtain the ScrollView object
  p = Mobile.Device().Process("com.example.myapp")
  ScrollView = p.RootLayout("").Layout("layoutTop").Layout("layout1").ScrollView("VerticalScrollView1")
  
  # Obtain the wPosition value
  Position = ScrollView.wPosition
  
  # Post the position to the log
  Log.Message(Position)

VBScript

Sub Test()

  ' Select the Android device
  Mobile.SetCurrent("MyDevice")
   
  ' Obtain the ScrollView object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set ScrollView = p.RootLayout("").Layout("layoutTop").Layout("layout1").ScrollView("VerticalScrollView1")
  
  ' Obtain the wPosition value
  Position = ScrollView.wPosition
  
  ' Post the position to the log
  Log.Message(Position)
End Sub

DelphiScript

procedure Test();
var
  p, ScrollView, Position : OleVariant;
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');
   
  // Obtain the ScrollView object
  p := Mobile.Device.Process('com.example.myapp');
  ScrollView := p.RootLayout('').Layout('layoutTop').Layout('layout1').ScrollView('VerticalScrollView1');
  
  // Obtain the wPosition value
  Position := ScrollView.wPosition;
  
  // Post the position to the log
  Log.Message(Position);
end;

C++Script, C#Script

function Test()
{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");
   
  // Obtain the ScrollView object
  var p = Mobile["Device"]["Process"]("com.example.myapp");
  var ScrollView = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1")["ScrollView"]("VerticalScrollView1");
  
  // Obtain the wPosition value
  var Position = ScrollView["wPosition"];
  
  // Post the position to the log
  Log["Message"](Position);
}

Using From Keyword Tests

This topic explains how to determine the current position of the scroll view control in scripts. You can use the described property in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.

See Also

Working With Android Scroll View Controls
Determining the Minimum and Maximum Scroll Vew Positions

Highlight search results