Changing Scroll View Position

Applies to TestComplete 15.63, last modified on April 22, 2024
Assigning wPosition Property

To assign a scroll view position, use the wPosition property. This property allows you to specify a value between the minimum and the maximum values of the scroll view. The assigned property defines the position of the scroll view relative to it's start in pixels. When you assign the position, no message is added to the test log.

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");
  
  // Assign the new value to wPosition property
  ScrollView.wPosition = 100;
}

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")
  
  # Assign the new value to wPosition property
  ScrollView.wPosition = 100

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")
  
  ' Assign the new value to wPosition property
  ScrollView.wPosition = 100
End Sub

DelphiScript

procedure Test();
var
  p, ScrollView : 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');
  
  // Assign the new value to wPosition property
  ScrollView.wPosition := 100;
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");
  
  // Assign the new value to wPosition property
  ScrollView["wPosition"] = 100;
}

If you try to assign the value above wMax or below wMin, the error message will be posted to the log and the wMax or wMin value will be assigned instead.
Using From Keyword Tests

This topic explains how to change the 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 Scroll View Position

Highlight search results