Working with Table View in Paging Mode

Applies to TestComplete 15.63, last modified on April 23, 2024

iOS table 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 table 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 table view, use the wPageCount property of the iOS TableView test object that TestComplete automatically associates with the table view control.

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

JavaScript, JScript

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

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

Determining Currently Selected Page

To determine which page is currently selected in the table view, you can use the wPage property of the iOS TableView test object TestComplete automatically associates with the table 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 tableview = p.Window().TableView();

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

Python

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

  # Check whether the needed page is selected
  if (tableview.wPage == 1):
    Log.Message("The second page is selected")
  else:
    tableview.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().TableView

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

DelphiScript

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

  // Check whether the needed page is selected
  if tableview.wPage = 1 then
    Log.Message('The second page is selected')
  else
    tableview.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 tableview = p["Window"]()["TableView"]();

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

Navigating Through Pages

To select the page preceding or following the page that is currently selected in the table view, you can use the Back and Next methods of the iOS TableView test object. To select an arbitrary page (specified by its index), you can call the ScrollToPage method of the iOS TableView 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 TableView object
  var p = Mobile.Device().Process("SampleApp");
  var tableview = p.Window().TableView();
  
  tableview.ScrollToPage(1)
}

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

Working with iOS TableView in Paging Mode From Keyword Tests

To work with table 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 Table View Controls
wPage Property (iOS Controls)
ScrollToPage Method (iOS Controls)
wPageCount Property (iOS Controls)
Next Method (iOS Controls)
Back Method (iOS Controls)

Highlight search results