Working with Multiline Edit Controls in Paging Mode

Applies to TestComplete 15.45, last modified on December 01, 2022

iOS text view controls support paging. When the paging mode of the control is enabled, it allows scrolling a single screen of content at a time.

Working with text view controls in paging mode is similar to working with iOS page controls.

Determining Number of Pages

To determine the number of pages in the text view control, use the wPageCount property of the iOS TextView test object that TestComplete automatically associates with the text view control.

The following sample code obtains the number of pages in the text view and posts it to the test log:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the TextView object
  var p = Mobile.Device().Process("SampleApp");
  var textview = p.Window().TextView();
  
  Log.Message(textview.wPageCount);
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the TextView object 
  p = Mobile.Device().Process("SampleApp")
  textview = p.Window().TextView()
  
  Log.Message(textview.wPageCount)

VBScript

Sub Test()
  Dim p, textview
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the TextView object
  Set p = Mobile.Device.Process("SampleApp")
  Set textview = p.Window.TextView
  
  Log.Message(textview.wPageCount)
End Sub

DelphiScript

procedure Test();
var
  p, textview;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the TextView object
  p := Mobile.Device.Process('SampleApp');
  textview := p.Window.TextView;
  
  Log.Message(textview.wPageCount);
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile["SetCurrent"]("iPhone");
  // Obtain the TextView object
  var p = Mobile["Device"].Process("SampleApp");
  var textview = p["Window"]()["TextView"]();
  
  Log["Message"](textview["wPageCount"]);
}

Determining Currently Selected Page

To determine which page is currently selected in the text view, use the wPage property of the iOS TextView test object TestComplete automatically associates with the text view control.

The sample code checks whether the second page is selected. If it is not, the code selects the needed page:

JavaScript, JScript

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

  // Check whether the needed page is selected
  if (textview.wPage == 1)
    Log.Message("The second page is selected");
  else
    textview.ScrollToPage(1);
}

Python

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

  # Check whether the needed page is selected
  if (textview.wPage == 1):
    Log.Message("The second page is selected")
  else:
    textview.ScrollToPage(1)

VBScript

Sub Test
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the PageControl object
  Set p = Mobile.Device.Process("SampleApp")
  Set pageControl = p.Window().TextView

  ' Check whether the needed page is selected
  If textview.wPage = 1 Then
    Log.Message("The second page is selected")
  Else
    textview.ScrollToPage(1)
  End If
End Sub

DelphiScript

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

  // Check whether the needed page is selected
  if textview.wPage = 1 then
    Log.Message('The second page is selected')
  else
    textview.ScrollToPage(1);
end;

C++Script, C#Script

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

  // Check whether the needed page is selected
  if (textview["wPage"] == 1)
    Log["Message"]("The second page is selected");
  else
    textview["ScrollToPage"](1);
}

Navigating Through Pages

To select the page preceding or following the page that is currently selected in the text view, you can use the Back and Next methods of the iOS TextView test object. To select an arbitrary page (specified by its index), you can call the ScrollToPage method of the iOS TextView object, or assign page index to the wPage property.

The code sample below demonstrates how to use these methods to navigate through pages:

JavaScript, JScript

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the TextView object
  var p = Mobile.Device().Process("SampleApp");
  var textview = p.Window().TextView();
  
  textview.ScrollToPage(1)
}

Python

def Test():
  # Select the mobile device
  Mobile.SetCurrent("iPhone")
  # Obtain the TextView object 
  p = Mobile.Device().Process("SampleApp")
  textview = p.Window().TextView()
  
  textview.ScrollToPage(1)

VBScript

Sub Test()
  Dim p, textview
  ' Select the mobile device
  Mobile.SetCurrent("iPhone")
  ' Obtain the TextView object
  Set p = Mobile.Device.Process("SampleApp")
  Set textview = p.Window.TextView
  
  textview.ScrollToPage(1)
End Sub

DelphiScript

procedure Test();
var
  p, textview;
begin
  // Select the mobile device
  Mobile.SetCurrent('iPhone');
  // Obtain the TextView object
  p := Mobile.Device.Process('SampleApp');
  textview := p.Window.TextView;
  
  textview.ScrollToPage(1)
end;

C++Script, C#Script

function Test()
{
  // Select the mobile device
  Mobile.SetCurrent("iPhone");
  // Obtain the TextView object
  var p = Mobile.Device.Process("SampleApp");
  var textview = p.Window().TextView();
  
  textview.ScrollToPage(1)
}

Working with iOS TextView in Paging Mode From Keyword Tests

To work with text view in paging mode 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 Text Edit Controls
wPage Property (iOS Controls)
ScrollToPage Method (iOS Controls)
wPageCount Property (iOS Controls)
Next Method (iOS Controls)
Back Method (iOS Controls)

Highlight search results